Skip to content

Commit ebd9023

Browse files
committed
[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.
1 parent f543122 commit ebd9023

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

libcxx/utils/libcxx/test/newformat.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import lit
1010
import os
1111
import pipes
12+
import re
1213

1314
class CxxStandardLibraryTest(lit.formats.TestFormat):
1415
"""
@@ -29,8 +30,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
2930
FOO.link.pass.cpp - Compiles and links successfully, run not attempted
3031
FOO.link.fail.cpp - Compiles successfully, but fails to link
3132
32-
FOO.sh.cpp - A builtin lit Shell test
33-
FOO.sh.s - A builtin lit Shell test
33+
FOO.sh.<anything> - A builtin Lit Shell test
3434
3535
FOO.verify.cpp - Compiles with clang-verify
3636
@@ -87,12 +87,12 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
8787
- It is unknown how well it works on Windows yet.
8888
"""
8989
def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
90-
SUPPORTED_SUFFIXES = ['.pass.cpp', '.pass.mm', '.run.fail.cpp',
91-
'.compile.pass.cpp', '.compile.fail.cpp',
92-
'.link.pass.cpp', '.link.fail.cpp',
93-
'.sh.cpp', '.sh.s',
94-
'.verify.cpp',
95-
'.fail.cpp']
90+
SUPPORTED_SUFFIXES = ['[.]pass[.]cpp$', '[.]pass[.]mm$', '[.]run[.]fail[.]cpp$',
91+
'[.]compile[.]pass[.]cpp$', '[.]compile[.]fail[.]cpp$',
92+
'[.]link[.]pass[.]cpp$', '[.]link[.]fail[.]cpp$',
93+
'[.]sh[.][^.]+$',
94+
'[.]verify[.]cpp$',
95+
'[.]fail[.]cpp$']
9696
sourcePath = testSuite.getSourcePath(pathInSuite)
9797
for filename in os.listdir(sourcePath):
9898
# Ignore dot files and excluded tests.
@@ -101,7 +101,7 @@ def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
101101

102102
filepath = os.path.join(sourcePath, filename)
103103
if not os.path.isdir(filepath):
104-
if any([filename.endswith(ext) for ext in SUPPORTED_SUFFIXES]):
104+
if any([re.search(ext, filename) for ext in SUPPORTED_SUFFIXES]):
105105
yield lit.Test.Test(testSuite, pathInSuite + (filename,), localConfig)
106106

107107
def _checkSubstitutions(self, substitutions):
@@ -136,7 +136,7 @@ def execute(self, test, litConfig):
136136
if '-fmodules' in test.config.available_features and self._disableWithModules(test, litConfig):
137137
return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test {} is unsupported when modules are enabled')
138138

139-
if filename.endswith('.sh.cpp') or filename.endswith('.sh.s'):
139+
if re.search('[.]sh[.][^.]+$', filename):
140140
steps = [ ] # The steps are already in the script
141141
return self._executeShTest(test, litConfig, steps)
142142
elif filename.endswith('.compile.pass.cpp'):

0 commit comments

Comments
 (0)