29
29
SRC_DIR = os .path .dirname (LIBASR_DIR )
30
30
ROOT_DIR = os .path .dirname (SRC_DIR )
31
31
32
+ no_color = False
32
33
33
34
class RunException (Exception ):
34
35
pass
@@ -329,7 +330,10 @@ def run_test(testname, basename, cmd, infile, update_reference=False,
329
330
raise RunException (
330
331
"Testing with reference output failed." +
331
332
full_err_str )
332
- log .debug (s + " " + check ())
333
+ if no_color :
334
+ log .debug (s + " PASS" )
335
+ else :
336
+ log .debug (s + " " + check ())
333
337
334
338
335
339
def tester_main (compiler , single_test ):
@@ -358,6 +362,8 @@ def tester_main(compiler, single_test):
358
362
help = "Skip runtime tests with debugging information enabled" )
359
363
parser .add_argument ("-s" , "--sequential" , action = "store_true" ,
360
364
help = "Run all tests sequentially" )
365
+ parser .add_argument ("--no-color" , action = "store_true" ,
366
+ help = "Turn off colored tests output" )
361
367
args = parser .parse_args ()
362
368
update_reference = args .update
363
369
list_tests = args .list
@@ -374,6 +380,8 @@ def tester_main(compiler, single_test):
374
380
verbose = args .verbose
375
381
no_llvm = args .no_llvm
376
382
skip_run_with_dbg = args .skip_run_with_dbg
383
+ global no_color
384
+ no_color = args .no_color
377
385
378
386
# So that the tests find the `lcompiler` executable
379
387
os .environ ["PATH" ] = os .path .join (SRC_DIR , "bin" ) \
@@ -401,7 +409,8 @@ def tester_main(compiler, single_test):
401
409
excluded_backends = excluded_backends ,
402
410
verbose = verbose ,
403
411
no_llvm = no_llvm ,
404
- skip_run_with_dbg = skip_run_with_dbg )
412
+ skip_run_with_dbg = skip_run_with_dbg ,
413
+ no_color = no_color )
405
414
# run in parallel
406
415
else :
407
416
single_tester_partial_args = partial (
@@ -411,7 +420,8 @@ def tester_main(compiler, single_test):
411
420
excluded_backends = excluded_backends ,
412
421
verbose = verbose ,
413
422
no_llvm = no_llvm ,
414
- skip_run_with_dbg = skip_run_with_dbg )
423
+ skip_run_with_dbg = skip_run_with_dbg ,
424
+ no_color = no_color )
415
425
with ThreadPoolExecutor () as ex :
416
426
futures = ex .map (single_tester_partial_args , filtered_tests )
417
427
for f in futures :
@@ -423,5 +433,9 @@ def tester_main(compiler, single_test):
423
433
if update_reference :
424
434
log .info ("Test references updated." )
425
435
else :
426
- log .info (
427
- f"{ (color (fg .green ) + color (style .bold ))} TESTS PASSED{ color (fg .reset ) + color (style .reset )} " )
436
+ if no_color :
437
+ log .info ("TESTS PASSED" )
438
+ else :
439
+ log .info (
440
+ f"{ (color (fg .green ) + color (style .bold ))} TESTS PASSED"
441
+ f"{ color (fg .reset ) + color (style .reset )} " )
0 commit comments