From b937549e517fcb03032bab3441d6ced37fc4db8d Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 21 Jul 2010 23:39:57 +0000 Subject: lit: Add support for 'REQUIRES: feature-one, feature-two, ...' in the integrated-test formats (sh and tcl style). The particular features which get recognized are up to the test suite itself to define. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109062 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/lit/lit/ExampleTests/lit.cfg | 3 +++ utils/lit/lit/TestRunner.py | 13 +++++++++++++ utils/lit/lit/TestingConfig.py | 9 ++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'utils') diff --git a/utils/lit/lit/ExampleTests/lit.cfg b/utils/lit/lit/ExampleTests/lit.cfg index dbd574f8bd..20ee37dcef 100644 --- a/utils/lit/lit/ExampleTests/lit.cfg +++ b/utils/lit/lit/ExampleTests/lit.cfg @@ -21,3 +21,6 @@ config.test_exec_root = None # target_triple: Used by ShTest and TclTest formats for XFAIL checks. config.target_triple = 'foo' + +# available_features: Used by ShTest and TclTest formats for REQUIRES checks. +config.available_features = ['some-feature-name'] diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py index cdf1c938af..3c2fe38473 100644 --- a/utils/lit/lit/TestRunner.py +++ b/utils/lit/lit/TestRunner.py @@ -422,6 +422,7 @@ def parseIntegratedTestScript(test, normalize_slashes=False): script = [] xfails = [] xtargets = [] + requires = [] for ln in open(sourcepath): if 'RUN:' in ln: # Isolate the command to run. @@ -442,6 +443,9 @@ def parseIntegratedTestScript(test, normalize_slashes=False): elif 'XTARGET:' in ln: items = ln[ln.index('XTARGET:') + 8:].split(',') xtargets.extend([s.strip() for s in items]) + elif 'REQUIRES:' in ln: + items = ln[ln.index('REQUIRES:') + 9:].split(',') + requires.extend([s.strip() for s in items]) elif 'END.' in ln: # Check for END. lines. if ln[ln.index('END.'):].strip() == 'END.': @@ -461,9 +465,18 @@ def parseIntegratedTestScript(test, normalize_slashes=False): if not script: return (Test.UNRESOLVED, "Test has no run line!") + # Check for unterminated run lines. if script[-1][-1] == '\\': return (Test.UNRESOLVED, "Test has unterminated run lines (with '\\')") + # Check that we have the required features: + missing_required_features = [f for f in requires + if f not in test.config.available_features] + if missing_required_features: + msg = ', '.join(missing_required_features) + return (Test.UNSUPPORTED, + "Test requires the following features: %s" % msg) + isXFail = isExpectedFail(xfails, xtargets, test.suite.config.target_triple) return script,isXFail,tmpBase,execdir diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py index dd905ef3ee..5c1b273948 100644 --- a/utils/lit/lit/TestingConfig.py +++ b/utils/lit/lit/TestingConfig.py @@ -28,7 +28,8 @@ class TestingConfig: on_clone = None, test_exec_root = None, test_source_root = None, - excludes = []) + excludes = [], + available_features = []) if os.path.exists(path): # FIXME: Improve detection and error reporting of errors in the @@ -54,7 +55,8 @@ class TestingConfig: def __init__(self, parent, name, suffixes, test_format, environment, substitutions, unsupported, on_clone, - test_exec_root, test_source_root, excludes): + test_exec_root, test_source_root, excludes, + available_features): self.parent = parent self.name = str(name) self.suffixes = set(suffixes) @@ -66,6 +68,7 @@ class TestingConfig: self.test_exec_root = test_exec_root self.test_source_root = test_source_root self.excludes = set(excludes) + self.available_features = set(available_features) def clone(self, path): # FIXME: Chain implementations? @@ -75,7 +78,7 @@ class TestingConfig: self.environment, self.substitutions, self.unsupported, self.on_clone, self.test_exec_root, self.test_source_root, - self.excludes) + self.excludes, self.available_features) if cfg.on_clone: cfg.on_clone(self, cfg, path) return cfg -- cgit v1.2.3