9
9
import lit
10
10
import os
11
11
import pipes
12
+ import re
12
13
13
14
class CxxStandardLibraryTest (lit .formats .TestFormat ):
14
15
"""
@@ -29,8 +30,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
29
30
FOO.link.pass.cpp - Compiles and links successfully, run not attempted
30
31
FOO.link.fail.cpp - Compiles successfully, but fails to link
31
32
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
34
34
35
35
FOO.verify.cpp - Compiles with clang-verify
36
36
@@ -87,12 +87,12 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
87
87
- It is unknown how well it works on Windows yet.
88
88
"""
89
89
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$ ' ]
96
96
sourcePath = testSuite .getSourcePath (pathInSuite )
97
97
for filename in os .listdir (sourcePath ):
98
98
# Ignore dot files and excluded tests.
@@ -101,7 +101,7 @@ def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):
101
101
102
102
filepath = os .path .join (sourcePath , filename )
103
103
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 ]):
105
105
yield lit .Test .Test (testSuite , pathInSuite + (filename ,), localConfig )
106
106
107
107
def _checkSubstitutions (self , substitutions ):
@@ -136,7 +136,7 @@ def execute(self, test, litConfig):
136
136
if '-fmodules' in test .config .available_features and self ._disableWithModules (test , litConfig ):
137
137
return lit .Test .Result (lit .Test .UNSUPPORTED , 'Test {} is unsupported when modules are enabled' )
138
138
139
- if filename . endswith ( '.sh.cpp' ) or filename . endswith ( '.sh.s' ):
139
+ if re . search ( '[.]sh[.][^.]+$' , filename ):
140
140
steps = [ ] # The steps are already in the script
141
141
return self ._executeShTest (test , litConfig , steps )
142
142
elif filename .endswith ('.compile.pass.cpp' ):
0 commit comments