diff --git a/swet/_main.py b/swet/_main.py index bf9303a6314429f647415dda9b264f4a2aba5f6a..c5f9785d8c2b5f62b9f0ecd9b27e83d8f3f9e2f8 100644 --- a/swet/_main.py +++ b/swet/_main.py @@ -22,6 +22,20 @@ def main(argv: Sequence[str] | None = None) -> int: help='Displays all available tests the tester could fined', ) + parser.add_argument( + '--no-use-colors', + dest='use_colors', + action='store_false', + help='Disable colorful output when running tests', + ) + + parser.add_argument( + '--use-colors', + dest='use_colors', + action='store_true', + help='Uses colorful output when running tests', + ) + parser.add_argument( '--run-tests', dest='run_tests', @@ -83,6 +97,7 @@ def main(argv: Sequence[str] | None = None) -> int: return_val = _run_tests( tests_to_run, args.build_path, + args.use_colors, args.testreport, ) diff --git a/swet/_testutils.py b/swet/_testutils.py index 2065a3f526900d61ce210ec94dc62a69f583c360..bc23210924666fc50c82aa06e5eefabf041bec93 100644 --- a/swet/_testutils.py +++ b/swet/_testutils.py @@ -109,6 +109,7 @@ def execute_test( testname: TestFile, build_path: str, code_path: str, + use_colors: bool, testreport: bool = False, ) -> int: @@ -138,7 +139,7 @@ def execute_test( with open( f'{build_path}/{testname.filename_without_ending}.log', ) as logfile: - for logline in follow(logfile, use_color=True): + for logline in follow(logfile, use_color=use_colors): if 'Assertion failed' in logline: test_result = Result.failed @@ -150,6 +151,7 @@ def execute_test( _print_testresult( testname.filename_without_ending.ljust(30, '.'), test_status=test_result, + use_colors=use_colors, ) if test_result == Result.failed: @@ -161,6 +163,7 @@ def execute_test( def _run_tests( tests_to_run: list[TestFile], build_path: str, + use_colors: bool, testreport: bool, ) -> int: @@ -233,6 +236,7 @@ def _run_tests( test, build_path, code_path, + use_colors, ) ret_val |= exec_test_ret_val