@@ -17,34 +17,34 @@ def log_print(*args, **kwargs):
1717class YaMuteCheck :
1818 def __init__ (self ):
1919 self .regexps = set ()
20+ self .regexps = []
2021
21- def add_unittest (self , fn ):
22+ def load (self , fn ):
2223 with open (fn , "r" ) as fp :
2324 for line in fp :
2425 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 ):
4848 return True
4949 return False
5050
@@ -176,8 +176,7 @@ def main():
176176 parser .add_argument (
177177 "-i" , action = "store_true" , dest = "save_inplace" , default = False , help = "modify input file in-place"
178178 )
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" )
181180 parser .add_argument ("--log-url-prefix" , default = "./" , help = "url prefix for logs" )
182181 parser .add_argument ("--log-out-dir" , help = "symlink logs to specific directory" )
183182 parser .add_argument (
@@ -194,11 +193,8 @@ def main():
194193
195194 mute_check = YaMuteCheck ()
196195
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 )
202198
203199 transform (
204200 args .in_file ,
0 commit comments