Skip to content

Commit f73302c

Browse files
committed
Improve failure message for uncounted suites
1 parent 1c2a4d1 commit f73302c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

easybuild/easyblocks/p/pytorch.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def test_step(self):
505505

506506
tests_out, tests_ec = parsed_test_result
507507

508-
# Show failed subtests to aid in debugging failures
508+
# Show failed subtests, if any, to aid in debugging failures
509509
failed_test_names = find_failed_test_names(tests_out)
510510
if failed_test_names.error or failed_test_names.fail:
511511
msg = []
@@ -520,17 +520,27 @@ def test_step(self):
520520
# Create clear summary report
521521
parsed_test_result = parse_test_log(tests_out)
522522
# Use a list of messages we can later join together
523-
failure_msgs = ['%s (%s)' % (suite.name, suite.summary) for suite in parsed_test_result.failed_suites]
523+
failure_msgs = ['\t%s (%s)' % (suite.name, suite.summary) for suite in parsed_test_result.failed_suites]
524+
# These were accounted for
524525
failed_test_suites = set(suite.name for suite in parsed_test_result.failed_suites)
526+
# Those are all that failed according to the summary output
525527
all_failed_test_suites = parsed_test_result.all_failed_suites
526-
# If we missed any test suites prepend a list of all failed test suites
528+
# We should have determined all failed test suites and only those.
529+
# Otherwise show the mismatch and terminate later
527530
if failed_test_suites != all_failed_test_suites:
528-
failure_msgs = ['Failed tests (suites/files):'] + failure_msgs
531+
failure_msgs.insert(0, 'Failed tests (suites/files):')
529532
# Test suites where we didn't match a specific regexp and hence likely didn't count the failures
530533
uncounted_test_suites = all_failed_test_suites - failed_test_suites
531534
if uncounted_test_suites:
532535
failure_msgs.append('Could not count failed tests for the following test suites/files:')
533-
failure_msgs.extend(sorted(uncounted_test_suites))
536+
for suite_name in sorted(uncounted_test_suites):
537+
try:
538+
signal = parsed_test_result.terminated_suites[suite_name]
539+
reason = f'Terminated with {signal}'
540+
except KeyError:
541+
# Not ended with signal, might have failed due to e.g. syntax errors
542+
reason = 'Did not run properly'
543+
failure_msgs.append(f'\t{suite_name} ({reason})')
534544
# Test suites not included in the catch-all regexp but counted. Should be empty.
535545
unexpected_test_suites = failed_test_suites - all_failed_test_suites
536546
if unexpected_test_suites:

0 commit comments

Comments
 (0)