[llvm] r223915 - [LIT] Add support for `UNSUPPORTED` tag to `TestRunner.parseIntegratedTestScript`

Eric Fiselier eric at efcs.ca
Tue Dec 9 19:42:10 PST 2014


Author: ericwf
Date: Tue Dec  9 21:42:09 2014
New Revision: 223915

URL: http://llvm.org/viewvc/llvm-project?rev=223915&view=rev
Log:
[LIT] Add support for `UNSUPPORTED` tag to `TestRunner.parseIntegratedTestScript`

Summary:
This patch gives me just enough to leverage the existing functionality in `TestRunner` for use in `libc++` and `libc++abi` .

It does the following:
* Adds the `UNSUPPORTED` tag to `TestRunner.parseIntegratedTestScript`.
* Allows `parseIntegratedTestScript` to return an empty script if a script is not required by the caller.



Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, llvm-commits

Differential Revision: http://reviews.llvm.org/D6589

Modified:
    llvm/trunk/utils/lit/lit/TestRunner.py
    llvm/trunk/utils/lit/lit/util.py

Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=223915&r1=223914&r2=223915&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Tue Dec  9 21:42:09 2014
@@ -7,6 +7,7 @@ import tempfile
 import lit.ShUtil as ShUtil
 import lit.Test as Test
 import lit.util
+from lit.util import to_bytes, to_string
 
 class InternalShellError(Exception):
     def __init__(self, command, message):
@@ -325,16 +326,8 @@ def parseIntegratedTestScriptCommands(so
     # UTF-8, so we convert the outputs to UTF-8 before returning. This way the
     # remaining code can work with "strings" agnostic of the executing Python
     # version.
-    
-    def to_bytes(str):
-        # Encode to UTF-8 to get binary data.
-        return str.encode('utf-8')
-    def to_string(bytes):
-        if isinstance(bytes, str):
-            return bytes
-        return to_bytes(bytes)
-        
-    keywords = ('RUN:', 'XFAIL:', 'REQUIRES:', 'END.')
+
+    keywords = ['RUN:', 'XFAIL:', 'REQUIRES:', 'UNSUPPORTED:', 'END.']
     keywords_re = re.compile(
         to_bytes("(%s)(.*)\n" % ("|".join(k for k in keywords),)))
 
@@ -368,11 +361,15 @@ def parseIntegratedTestScriptCommands(so
     finally:
         f.close()
 
+
 def parseIntegratedTestScript(test, normalize_slashes=False,
-                              extra_substitutions=[]):
+                              extra_substitutions=[], require_script=True):
     """parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
     script and extract the lines to 'RUN' as well as 'XFAIL' and 'REQUIRES'
-    information. The RUN lines also will have variable substitution performed.
+    and 'UNSUPPORTED' information. The RUN lines also will have variable
+    substitution performed. If 'require_script' is False an empty script may be
+    returned. This can be used for test formats where the actual script is
+    optional or ignored.
     """
 
     # Get the temporary location, this is always relative to the test suite
@@ -417,6 +414,7 @@ def parseIntegratedTestScript(test, norm
     # Collect the test lines from the script.
     script = []
     requires = []
+    unsupported = []
     for line_number, command_type, ln in \
             parseIntegratedTestScriptCommands(sourcepath):
         if command_type == 'RUN':
@@ -441,6 +439,8 @@ def parseIntegratedTestScript(test, norm
             test.xfails.extend([s.strip() for s in ln.split(',')])
         elif command_type == 'REQUIRES':
             requires.extend([s.strip() for s in ln.split(',')])
+        elif command_type == 'UNSUPPORTED':
+            unsupported.extend([s.strip() for s in ln.split(',')])
         elif command_type == 'END':
             # END commands are only honored if the rest of the line is empty.
             if not ln.strip():
@@ -465,11 +465,11 @@ def parseIntegratedTestScript(test, norm
               for ln in script]
 
     # Verify the script contains a run line.
-    if not script:
+    if require_script and not script:
         return lit.Test.Result(Test.UNRESOLVED, "Test has no run line!")
 
     # Check for unterminated run lines.
-    if script[-1][-1] == '\\':
+    if script and script[-1][-1] == '\\':
         return lit.Test.Result(Test.UNRESOLVED,
                                "Test has unterminated run lines (with '\\')")
 
@@ -480,6 +480,12 @@ def parseIntegratedTestScript(test, norm
         msg = ', '.join(missing_required_features)
         return lit.Test.Result(Test.UNSUPPORTED,
                                "Test requires the following features: %s" % msg)
+    unsupported_features = [f for f in unsupported
+                            if f in test.config.available_features]
+    if unsupported_features:
+        msg = ', '.join(unsupported_features)
+        return lit.Test.Result(Test.UNSUPPORTED,
+                    "Test is unsupported with the following features: %s" % msg)
 
     return script,tmpBase,execdir
 

Modified: llvm/trunk/utils/lit/lit/util.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/util.py?rev=223915&r1=223914&r2=223915&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/util.py (original)
+++ llvm/trunk/utils/lit/lit/util.py Tue Dec  9 21:42:09 2014
@@ -7,6 +7,15 @@ import signal
 import subprocess
 import sys
 
+def to_bytes(str):
+    # Encode to UTF-8 to get binary data.
+    return str.encode('utf-8')
+
+def to_string(bytes):
+    if isinstance(bytes, str):
+        return bytes
+    return to_bytes(bytes)
+
 def detectCPUs():
     """
     Detects the number of CPUs on a system. Cribbed from pp.
@@ -156,11 +165,6 @@ def executeCommand(command, cwd=None, en
     if exitCode == -signal.SIGINT:
         raise KeyboardInterrupt
 
-    def to_string(bytes):
-        if isinstance(bytes, str):
-            return bytes
-        return bytes.encode('utf-8')
-
     # Ensure the resulting output is always of string type.
     try:
         out = to_string(out.decode('utf-8'))





More information about the llvm-commits mailing list