@@ -17,34 +17,34 @@ def log_print(*args, **kwargs):
17
17
class YaMuteCheck :
18
18
def __init__ (self ):
19
19
self .regexps = set ()
20
+ self .regexps = []
20
21
21
- def add_unittest (self , fn ):
22
+ def load (self , fn ):
22
23
with open (fn , "r" ) as fp :
23
24
for line in fp :
24
25
line = line .strip ()
25
- path , rest = line .split ("/" , maxsplit = 1 )
26
- path = path .replace ("-" , "/" )
27
- rest = rest .replace ("::" , "." )
28
- self .populate (f"{ path } /{ rest } " )
29
-
30
- def add_functest (self , fn ):
31
- with open (fn , "r" ) as fp :
32
- for line in fp :
33
- line = line .strip ()
34
- line = line .replace ("::" , "." )
35
- self .populate (line )
36
-
37
- def populate (self , line ):
38
- pattern = pattern_to_re (line )
39
-
40
- try :
41
- self .regexps .add (re .compile (pattern ))
42
- except re .error :
43
- log_print (f"Unable to compile regex { pattern !r} " )
44
-
45
- def __call__ (self , suitename , testname ):
46
- for r in self .regexps :
47
- if r .match (f"{ suitename } /{ testname } " ):
26
+ try :
27
+ testsuite , testcase = line .split (" " , maxsplit = 1 )
28
+ except ValueError :
29
+ log_print (f"SKIP INVALID MUTE CONFIG LINE: { line !r} " )
30
+ continue
31
+ self .populate (testsuite , testcase )
32
+
33
+ def populate (self , testsuite , testcase ):
34
+ check = []
35
+
36
+ for p in (pattern_to_re (testsuite ), pattern_to_re (testcase )):
37
+ try :
38
+ check .append (re .compile (p ))
39
+ except re .error :
40
+ log_print (f"Unable to compile regex { p !r} " )
41
+ return
42
+
43
+ self .regexps .append (tuple (check ))
44
+
45
+ def __call__ (self , suite_name , test_name ):
46
+ for ps , pt in self .regexps :
47
+ if ps .match (suite_name ) and pt .match (test_name ):
48
48
return True
49
49
return False
50
50
@@ -176,8 +176,7 @@ def main():
176
176
parser .add_argument (
177
177
"-i" , action = "store_true" , dest = "save_inplace" , default = False , help = "modify input file in-place"
178
178
)
179
- parser .add_argument ("--mu" , help = "unittest mute config" )
180
- parser .add_argument ("--mf" , help = "functional test mute config" )
179
+ parser .add_argument ("-m" , help = "muted test list" )
181
180
parser .add_argument ("--log-url-prefix" , default = "./" , help = "url prefix for logs" )
182
181
parser .add_argument ("--log-out-dir" , help = "symlink logs to specific directory" )
183
182
parser .add_argument (
@@ -194,11 +193,8 @@ def main():
194
193
195
194
mute_check = YaMuteCheck ()
196
195
197
- if args .mu :
198
- mute_check .add_unittest (args .mu )
199
-
200
- if args .mf :
201
- mute_check .add_functest (args .mf )
196
+ if args .m :
197
+ mute_check .load (args .m )
202
198
203
199
transform (
204
200
args .in_file ,
0 commit comments