lit: Add support for 'REQUIRES: feature-one, feature-two, ...' in the
authorDaniel Dunbar <daniel@zuster.org>
Wed, 21 Jul 2010 23:39:57 +0000 (23:39 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 21 Jul 2010 23:39:57 +0000 (23:39 +0000)
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
utils/lit/lit/TestRunner.py
utils/lit/lit/TestingConfig.py

index dbd574f8bd1058f8a8fc6f600e612f284adbd499..20ee37dcef2782536046e7cb112a2560888d68e8 100644 (file)
@@ -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']
index cdf1c938af8c75634fd30a19fa4e36de7b00a493..3c2fe38473932270398d9f85390620046ea24e00 100644 (file)
@@ -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
 
index dd905ef3ee10f623908eaa685995a263a09f6a53..5c1b273948575d7ee6c3dcd42e5b2b2e336a476e 100644 (file)
@@ -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