Skip to content

Commit ad6b324

Browse files
Thirumalai-Shaktivelczgdp1807
authored andcommitted
Add no_color option in run_tests.py
1 parent 2ad5761 commit ad6b324

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

ci/test.xsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ src/bin/lpython --show-asr tests/doconcurrentloop_01.py
1616
src/bin/lpython --show-cpp tests/doconcurrentloop_01.py
1717

1818
if $WIN == "1":
19-
python run_tests.py --skip-run-with-dbg
19+
python run_tests.py --skip-run-with-dbg --no-color
2020
else:
2121
python run_tests.py
2222
cd integration_tests

run_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def single_test(test, verbose, no_llvm, skip_run_with_dbg, update_reference,
13-
specific_backends=None, excluded_backends=None):
13+
no_color, specific_backends=None, excluded_backends=None):
1414
filename = test["filename"]
1515
def is_included(backend):
1616
return test.get(backend, False) \
@@ -36,7 +36,10 @@ def is_included(backend):
3636
if pass_ and (pass_ not in ["do_loops", "global_stmts"] and
3737
pass_ not in optimization_passes):
3838
raise Exception(f"Unknown pass: {pass_}")
39-
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")
39+
if no_color:
40+
log.debug(f" START TEST: {filename}")
41+
else:
42+
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")
4043

4144
extra_args = f"--no-error-banner {show_verbose}"
4245

src/libasr/compiler_tester/tester.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
SRC_DIR = os.path.dirname(LIBASR_DIR)
3030
ROOT_DIR = os.path.dirname(SRC_DIR)
3131

32+
no_color = False
3233

3334
class RunException(Exception):
3435
pass
@@ -329,7 +330,10 @@ def run_test(testname, basename, cmd, infile, update_reference=False,
329330
raise RunException(
330331
"Testing with reference output failed." +
331332
full_err_str)
332-
log.debug(s + " " + check())
333+
if no_color:
334+
log.debug(s + " PASS")
335+
else:
336+
log.debug(s + " " + check())
333337

334338

335339
def tester_main(compiler, single_test):
@@ -358,6 +362,8 @@ def tester_main(compiler, single_test):
358362
help="Skip runtime tests with debugging information enabled")
359363
parser.add_argument("-s", "--sequential", action="store_true",
360364
help="Run all tests sequentially")
365+
parser.add_argument("--no-color", action="store_true",
366+
help="Turn off colored tests output")
361367
args = parser.parse_args()
362368
update_reference = args.update
363369
list_tests = args.list
@@ -374,6 +380,8 @@ def tester_main(compiler, single_test):
374380
verbose = args.verbose
375381
no_llvm = args.no_llvm
376382
skip_run_with_dbg = args.skip_run_with_dbg
383+
global no_color
384+
no_color = args.no_color
377385

378386
# So that the tests find the `lcompiler` executable
379387
os.environ["PATH"] = os.path.join(SRC_DIR, "bin") \
@@ -401,7 +409,8 @@ def tester_main(compiler, single_test):
401409
excluded_backends=excluded_backends,
402410
verbose=verbose,
403411
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)
405414
# run in parallel
406415
else:
407416
single_tester_partial_args = partial(
@@ -411,7 +420,8 @@ def tester_main(compiler, single_test):
411420
excluded_backends=excluded_backends,
412421
verbose=verbose,
413422
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)
415425
with ThreadPoolExecutor() as ex:
416426
futures = ex.map(single_tester_partial_args, filtered_tests)
417427
for f in futures:
@@ -423,5 +433,9 @@ def tester_main(compiler, single_test):
423433
if update_reference:
424434
log.info("Test references updated.")
425435
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

Comments
 (0)