diff options
author | Marijan Petričević <marijan.petricevic94@gmail.com> | 2020-01-14 09:33:10 +0100 |
---|---|---|
committer | Marijan Petričević <marijan.petricevic94@gmail.com> | 2020-01-14 09:33:10 +0100 |
commit | 61c61f80e58b24c969f0ea1d0d069e70ddc37be3 (patch) | |
tree | 97f05d584e7e2ebcd111ec681f4b50311b659d98 /nixos/lib/test-driver | |
parent | 2ac5fab2647895a95fe9cf877faa9ce648a7be7c (diff) |
nixos/test: added verbose output for failed tests
Diffstat (limited to 'nixos/lib/test-driver')
-rw-r--r-- | nixos/lib/test-driver/test-driver.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py index 7e575189209a..7dac9783c1a8 100644 --- a/nixos/lib/test-driver/test-driver.py +++ b/nixos/lib/test-driver/test-driver.py @@ -84,7 +84,7 @@ CHAR_TO_KEY = { # Forward references nr_tests: int -nr_succeeded: int +failed_tests: list log: "Logger" machines: "List[Machine]" @@ -841,23 +841,31 @@ def run_tests() -> None: machine.execute("sync") if nr_tests != 0: + nr_succeeded = nr_tests - len(failed_tests) eprint("{} out of {} tests succeeded".format(nr_succeeded, nr_tests)) - if nr_tests > nr_succeeded: + if len(failed_tests) > 0: + eprint( + "The following tests have failed:\n - {}".format( + "\n - ".join(failed_tests) + ) + ) sys.exit(1) @contextmanager def subtest(name: str) -> Iterator[None]: global nr_tests - global nr_succeeded + global failed_tests with log.nested(name): nr_tests += 1 try: yield - nr_succeeded += 1 return True except Exception as e: + failed_tests.append( + 'Test "{}" failed with error: "{}"'.format(name, str(e)) + ) log.log("error: {}".format(str(e))) return False @@ -879,7 +887,7 @@ if __name__ == "__main__": exec("\n".join(machine_eval)) nr_tests = 0 - nr_succeeded = 0 + failed_tests = [] @atexit.register def clean_up() -> None: |