@@ -270,6 +270,18 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
270
270
default = None ,
271
271
help = "Run specific tests using their short names separated by comma" ,
272
272
)
273
+ parser .add_argument (
274
+ "-N" ,
275
+ type = str ,
276
+ default = None ,
277
+ help = "Exclude specific tests by number, format is 1,3-6,9" ,
278
+ )
279
+ parser .add_argument (
280
+ "-S" ,
281
+ type = str ,
282
+ default = None ,
283
+ help = "Exclude specific tests by short names separated by comma" ,
284
+ )
273
285
parser .add_argument (
274
286
"--tool" ,
275
287
type = str ,
@@ -340,6 +352,15 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
340
352
341
353
return parser
342
354
355
+ def expand_number_range (nr : str ) -> List [int ]:
356
+ ans : List [int ] = []
357
+ for s in nr .split ("," ):
358
+ sp = s .split ("-" )
359
+ if len (sp ) == 2 :
360
+ ans .extend (range (int (sp [0 ]) - 1 , int (sp [1 ])))
361
+ else :
362
+ ans .append (int (s ) - 1 )
363
+ return ans
343
364
344
365
def main (): # type: () -> int
345
366
@@ -430,12 +451,7 @@ def main(): # type: () -> int
430
451
if args .n is not None or args .s is not None :
431
452
ntest = []
432
453
if args .n is not None :
433
- for s in args .n .split ("," ):
434
- sp = s .split ("-" )
435
- if len (sp ) == 2 :
436
- ntest .extend (list (range (int (sp [0 ]) - 1 , int (sp [1 ]))))
437
- else :
438
- ntest .append (int (s ) - 1 )
454
+ ntest = expand_number_range (args .n )
439
455
if args .s is not None :
440
456
for s in args .s .split ("," ):
441
457
test_number = get_test_number_by_key (tests , "short_name" , s )
@@ -447,6 +463,20 @@ def main(): # type: () -> int
447
463
else :
448
464
ntest = list (range (0 , len (tests )))
449
465
466
+ exclude_n = []
467
+ if args .N is not None :
468
+ exclude_n = expand_number_range (args .N )
469
+ if args .S is not None :
470
+ for s in args .S .split ("," ):
471
+ test_number = get_test_number_by_key (tests , "short_name" , s )
472
+ if test_number :
473
+ exclude_n .append (test_number )
474
+ else :
475
+ _logger .error ('Test with short name "%s" not found ' , s )
476
+ return 1
477
+
478
+ ntest = list (filter (lambda x : x not in exclude_n , ntest ))
479
+
450
480
total = 0
451
481
with ThreadPoolExecutor (max_workers = args .j ) as executor :
452
482
jobs = [
0 commit comments