From 8c6c1fbba53c0e4a66dc974417eb9dee57103879 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Fri, 23 Dec 2022 17:12:34 -0800 Subject: [PATCH 1/5] test: print failed JS/parallel tests --- tools/test.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/test.py b/tools/test.py index d1c74a3d5f909b..ed9d4bad37073e 100755 --- a/tools/test.py +++ b/tools/test.py @@ -172,7 +172,10 @@ def Run(self, tasks): # ...and then reraise the exception to bail out raise self.Done() - return not self.failed + return { + 'allPassed': not self.failed, + 'failed': self.failed, + } def RunSingle(self, parallel, thread_id): while not self.shutdown_event.is_set(): @@ -1757,10 +1760,8 @@ def should_keep(case): else: try: start = time.time() - if RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests, options.measure_flakiness): - result = 0 - else: - result = 1 + result = RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests, options.measure_flakiness) + exitCode = 0 if result['allPassed'] else 1 duration = time.time() - start except KeyboardInterrupt: print("Interrupted") @@ -1777,7 +1778,14 @@ def should_keep(case): t = FormatTimedelta(entry.duration) sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel())) - return result + if result['allPassed']: + print('All tests passed.') + else: + print('Failed tests:') + for failedTest in result['failed']: + print(EscapeCommand(failedTest.command)) + + return exitCode if __name__ == '__main__': From 639e1a8e19cf80080310c5fc722948c818e17622 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sat, 24 Dec 2022 15:33:05 -0800 Subject: [PATCH 2/5] add type hint --- tools/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index ed9d4bad37073e..8609bf5b6f2b26 100755 --- a/tools/test.py +++ b/tools/test.py @@ -147,7 +147,7 @@ def PrintFailureHeader(self, test): }) print("Path: %s" % "/".join(test.path)) - def Run(self, tasks): + def Run(self, tasks) -> dict: self.Starting() threads = [] # Spawn N-1 threads and then use this thread as the last one. From a645ef6f44904d413fe7510d8a36647fd213f136 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sat, 24 Dec 2022 15:38:07 -0800 Subject: [PATCH 3/5] Add newline between failed test outputs --- tools/test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/test.py b/tools/test.py index 8609bf5b6f2b26..0e4da26fc5469d 100755 --- a/tools/test.py +++ b/tools/test.py @@ -482,6 +482,7 @@ def HasRun(self, output): print("--- %s ---" % PrintCrashed(output.output.exit_code)) if output.HasTimedOut(): print("--- TIMEOUT ---") + print("\n") # Two blank lines between failures, for visual separation def Truncate(self, str, length): if length and (len(str) > (length - 3)): @@ -1779,9 +1780,9 @@ def should_keep(case): sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel())) if result['allPassed']: - print('All tests passed.') + print("\nAll tests passed.") else: - print('Failed tests:') + print("\nFailed tests:") for failedTest in result['failed']: print(EscapeCommand(failedTest.command)) From fa700722421db0c35ec7677f289df923b184992e Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sat, 24 Dec 2022 16:20:20 -0800 Subject: [PATCH 4/5] Match style for variable names --- tools/test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/test.py b/tools/test.py index 0e4da26fc5469d..795f61eff08228 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1762,7 +1762,7 @@ def should_keep(case): try: start = time.time() result = RunTestCases(cases_to_run, options.progress, options.j, options.flaky_tests, options.measure_flakiness) - exitCode = 0 if result['allPassed'] else 1 + exitcode = 0 if result['allPassed'] else 1 duration = time.time() - start except KeyboardInterrupt: print("Interrupted") @@ -1783,10 +1783,10 @@ def should_keep(case): print("\nAll tests passed.") else: print("\nFailed tests:") - for failedTest in result['failed']: - print(EscapeCommand(failedTest.command)) + for failure in result['failed']: + print(EscapeCommand(failure.command)) - return exitCode + return exitcode if __name__ == '__main__': From 193fdc09d582a62cc0097a6dee363ab59157b043 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Mon, 26 Dec 2022 10:35:42 -0800 Subject: [PATCH 5/5] Add import for backward compatibility --- tools/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 795f61eff08228..cdcd6c148278e2 100755 --- a/tools/test.py +++ b/tools/test.py @@ -29,6 +29,7 @@ from __future__ import print_function +from typing import Dict import logging import optparse import os @@ -147,7 +148,7 @@ def PrintFailureHeader(self, test): }) print("Path: %s" % "/".join(test.path)) - def Run(self, tasks) -> dict: + def Run(self, tasks) -> Dict: self.Starting() threads = [] # Spawn N-1 threads and then use this thread as the last one.