Skip to content

Commit

Permalink
Add no_color option in run_tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel authored and czgdp1807 committed Jan 31, 2023
1 parent 2ad5761 commit ad6b324
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ci/test.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ src/bin/lpython --show-asr tests/doconcurrentloop_01.py
src/bin/lpython --show-cpp tests/doconcurrentloop_01.py

if $WIN == "1":
python run_tests.py --skip-run-with-dbg
python run_tests.py --skip-run-with-dbg --no-color
else:
python run_tests.py
cd integration_tests
Expand Down
7 changes: 5 additions & 2 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def single_test(test, verbose, no_llvm, skip_run_with_dbg, update_reference,
specific_backends=None, excluded_backends=None):
no_color, specific_backends=None, excluded_backends=None):
filename = test["filename"]
def is_included(backend):
return test.get(backend, False) \
Expand All @@ -36,7 +36,10 @@ def is_included(backend):
if pass_ and (pass_ not in ["do_loops", "global_stmts"] and
pass_ not in optimization_passes):
raise Exception(f"Unknown pass: {pass_}")
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")
if no_color:
log.debug(f" START TEST: {filename}")
else:
log.debug(f"{color(style.bold)} START TEST: {color(style.reset)} {filename}")

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

Expand Down
24 changes: 19 additions & 5 deletions src/libasr/compiler_tester/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SRC_DIR = os.path.dirname(LIBASR_DIR)
ROOT_DIR = os.path.dirname(SRC_DIR)

no_color = False

class RunException(Exception):
pass
Expand Down Expand Up @@ -329,7 +330,10 @@ def run_test(testname, basename, cmd, infile, update_reference=False,
raise RunException(
"Testing with reference output failed." +
full_err_str)
log.debug(s + " " + check())
if no_color:
log.debug(s + " PASS")
else:
log.debug(s + " " + check())


def tester_main(compiler, single_test):
Expand Down Expand Up @@ -358,6 +362,8 @@ def tester_main(compiler, single_test):
help="Skip runtime tests with debugging information enabled")
parser.add_argument("-s", "--sequential", action="store_true",
help="Run all tests sequentially")
parser.add_argument("--no-color", action="store_true",
help="Turn off colored tests output")
args = parser.parse_args()
update_reference = args.update
list_tests = args.list
Expand All @@ -374,6 +380,8 @@ def tester_main(compiler, single_test):
verbose = args.verbose
no_llvm = args.no_llvm
skip_run_with_dbg = args.skip_run_with_dbg
global no_color
no_color = args.no_color

# So that the tests find the `lcompiler` executable
os.environ["PATH"] = os.path.join(SRC_DIR, "bin") \
Expand Down Expand Up @@ -401,7 +409,8 @@ def tester_main(compiler, single_test):
excluded_backends=excluded_backends,
verbose=verbose,
no_llvm=no_llvm,
skip_run_with_dbg=skip_run_with_dbg)
skip_run_with_dbg=skip_run_with_dbg,
no_color=no_color)
# run in parallel
else:
single_tester_partial_args = partial(
Expand All @@ -411,7 +420,8 @@ def tester_main(compiler, single_test):
excluded_backends=excluded_backends,
verbose=verbose,
no_llvm=no_llvm,
skip_run_with_dbg=skip_run_with_dbg)
skip_run_with_dbg=skip_run_with_dbg,
no_color=no_color)
with ThreadPoolExecutor() as ex:
futures = ex.map(single_tester_partial_args, filtered_tests)
for f in futures:
Expand All @@ -423,5 +433,9 @@ def tester_main(compiler, single_test):
if update_reference:
log.info("Test references updated.")
else:
log.info(
f"{(color(fg.green) + color(style.bold))}TESTS PASSED{color(fg.reset) + color(style.reset)}")
if no_color:
log.info("TESTS PASSED")
else:
log.info(
f"{(color(fg.green) + color(style.bold))}TESTS PASSED"
f"{color(fg.reset) + color(style.reset)}")

0 comments on commit ad6b324

Please sign in to comment.