[libcxx-commits] [libcxx] ebd9023 - [libc++] Support arbitrary .sh.X extensions in the new format

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 16 06:56:32 PDT 2020


Author: Louis Dionne
Date: 2020-04-16T09:55:03-04:00
New Revision: ebd90232fbe046dcfd518252eae842eccc111e88

URL: https://github.com/llvm/llvm-project/commit/ebd90232fbe046dcfd518252eae842eccc111e88
DIFF: https://github.com/llvm/llvm-project/commit/ebd90232fbe046dcfd518252eae842eccc111e88.diff

LOG: [libc++] Support arbitrary .sh.X extensions in the new format

This allows writing all kinds of ShTests, for example .sh.py tests for
testing Python code.

Added: 
    

Modified: 
    libcxx/utils/libcxx/test/newformat.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/newformat.py b/libcxx/utils/libcxx/test/newformat.py
index 10c6ff325402..5e8e90706eaf 100644
--- a/libcxx/utils/libcxx/test/newformat.py
+++ b/libcxx/utils/libcxx/test/newformat.py
@@ -9,6 +9,7 @@
 import lit
 import os
 import pipes
+import re
 
 class CxxStandardLibraryTest(lit.formats.TestFormat):
     """
@@ -29,8 +30,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
     FOO.link.pass.cpp       - Compiles and links successfully, run not attempted
     FOO.link.fail.cpp       - Compiles successfully, but fails to link
 
-    FOO.sh.cpp              - A builtin lit Shell test
-    FOO.sh.s                - A builtin lit Shell test
+    FOO.sh.<anything>       - A builtin Lit Shell test
 
     FOO.verify.cpp          - Compiles with clang-verify
 
@@ -87,12 +87,12 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
         - It is unknown how well it works on Windows yet.
     """
     def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
-        SUPPORTED_SUFFIXES = ['.pass.cpp', '.pass.mm', '.run.fail.cpp',
-                              '.compile.pass.cpp', '.compile.fail.cpp',
-                              '.link.pass.cpp', '.link.fail.cpp',
-                              '.sh.cpp', '.sh.s',
-                              '.verify.cpp',
-                              '.fail.cpp']
+        SUPPORTED_SUFFIXES = ['[.]pass[.]cpp$', '[.]pass[.]mm$', '[.]run[.]fail[.]cpp$',
+                              '[.]compile[.]pass[.]cpp$', '[.]compile[.]fail[.]cpp$',
+                              '[.]link[.]pass[.]cpp$', '[.]link[.]fail[.]cpp$',
+                              '[.]sh[.][^.]+$',
+                              '[.]verify[.]cpp$',
+                              '[.]fail[.]cpp$']
         sourcePath = testSuite.getSourcePath(pathInSuite)
         for filename in os.listdir(sourcePath):
             # Ignore dot files and excluded tests.
@@ -101,7 +101,7 @@ def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
 
             filepath = os.path.join(sourcePath, filename)
             if not os.path.isdir(filepath):
-                if any([filename.endswith(ext) for ext in SUPPORTED_SUFFIXES]):
+                if any([re.search(ext, filename) for ext in SUPPORTED_SUFFIXES]):
                     yield lit.Test.Test(testSuite, pathInSuite + (filename,), localConfig)
 
     def _checkSubstitutions(self, substitutions):
@@ -136,7 +136,7 @@ def execute(self, test, litConfig):
         if '-fmodules' in test.config.available_features and self._disableWithModules(test, litConfig):
             return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test {} is unsupported when modules are enabled')
 
-        if filename.endswith('.sh.cpp') or filename.endswith('.sh.s'):
+        if re.search('[.]sh[.][^.]+$', filename):
             steps = [ ] # The steps are already in the script
             return self._executeShTest(test, litConfig, steps)
         elif filename.endswith('.compile.pass.cpp'):


        


More information about the libcxx-commits mailing list