99import lit
1010import os
1111import pipes
12+ import re
1213
1314class 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