Skip to content

Commit

Permalink
test: print failed JS/parallel tests
Browse files Browse the repository at this point in the history
PR-URL: #45960
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Christian Clauss <cclauss@me.com>
  • Loading branch information
GeoffreyBooth authored and juanarbol committed Jan 31, 2023
1 parent 7812752 commit 4d6dd10
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tools/test.py
Expand Up @@ -29,6 +29,7 @@


from __future__ import print_function
from typing import Dict
import logging
import optparse
import os
Expand Down Expand Up @@ -147,7 +148,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.
Expand All @@ -172,7 +173,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():
Expand Down Expand Up @@ -479,6 +483,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)):
Expand Down Expand Up @@ -1757,10 +1762,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")
Expand All @@ -1777,7 +1780,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("\nAll tests passed.")
else:
print("\nFailed tests:")
for failure in result['failed']:
print(EscapeCommand(failure.command))

return exitcode


if __name__ == '__main__':
Expand Down

0 comments on commit 4d6dd10

Please sign in to comment.