diff --git a/mjtest/cli.py b/mjtest/cli.py index d1cff7ecece57c39cda7d095eafb277bc347928b..b4b01a0178f97491d1431750d6e7fa2423cd457d 100644 --- a/mjtest/cli.py +++ b/mjtest/cli.py @@ -40,6 +40,8 @@ if True:#__name__ == '__main__': help="Produce no long reports besides the command line output") parser.add_argument("--parallel", action="store_true", default=False, help="Run the tests in parallel") + parser.add_argument("--output_incorrect_reports", action="store_true", default=True, + help="Output the long report for every incorrect test case") #parser.add_argument("--timeout", action="store_const", default=30, const="timeout", # help="Abort a program after TIMEOUT seconds") #parser.add_argument("--report_dir", action="store_const", default="", const="report_dir", diff --git a/mjtest/environment.py b/mjtest/environment.py index 747321a0fa59beff2503f3064c995afbb2e9a10d..32280bbede8d810182602f98b259c265cebdd779 100644 --- a/mjtest/environment.py +++ b/mjtest/environment.py @@ -30,7 +30,7 @@ class Environment: def __init__(self, mode, mj_run: str, tmp_dir: str = "", test_dir: str = "", only_incorrect_tests: bool = False, parallel: bool = False, timeout: int = 30, report_dir: str = "", log_level: str = "warn", - produce_no_reports: bool = True): + produce_no_reports: bool = True, output_incorrect_reports: bool = True): self.mode = mode self.mj_run_cmd = os.path.realpath(mj_run) @@ -70,6 +70,7 @@ class Environment: self.report_dir = None logging.basicConfig(level=self.LOG_LEVELS[log_level]) self.produce_reports = not produce_no_reports # type: bool + self.output_incorrect_reports = True def create_tmpfile(self) -> str: return os.path.join(self.tmp_dir, str(os.times())) diff --git a/mjtest/test/tests.py b/mjtest/test/tests.py index 535317bcd296a13d0338e1e07c22821f2b54922c..1f852ec216a57dfc292310cc762d228223b35fd9 100644 --- a/mjtest/test/tests.py +++ b/mjtest/test/tests.py @@ -146,6 +146,9 @@ class TestSuite: os.mkdir(rep_dir) suffix = ".correct" if ret.is_correct() else ".incorrect" ret.store_at(join(rep_dir, test_case.short_name() + suffix)) + if self.env.output_incorrect_reports and not ret.is_correct(): + print(colored("Report for failing test case {}".format(test_case.short_name()), "red", attrs=["bold"])) + print(colored(ret.long_message(), "red")) return ret except IOError: _LOG.exception("Caught i/o error while trying to store the report for '{}'"