| ... |
... |
@@ -3527,9 +3527,22 @@ def findTFiles(roots: List[str]) -> Iterator[str]: |
|
3527
|
3527
|
# -----------------------------------------------------------------------------
|
|
3528
|
3528
|
# Output a test summary to the specified file object
|
|
3529
|
3529
|
|
|
3530
|
|
-def summary(t: TestRun, file: TextIO, color=False) -> None:
|
|
|
3530
|
+def summary(t: TestRun, file: TextIO, color=False, junit_path: Optional[Path]=None) -> None:
|
|
3531
|
3531
|
|
|
3532
|
3532
|
file.write('\n')
|
|
|
3533
|
+
|
|
|
3534
|
+ if t.unexpected_failures:
|
|
|
3535
|
+ if len(t.unexpected_failures) > MAX_SUMMARY_OUTPUT_TESTS:
|
|
|
3536
|
+ # junit.xml only exists when a path was requested (e.g. in CI); don't
|
|
|
3537
|
+ # point at a file that a local run never wrote.
|
|
|
3538
|
+ where = 'see {}'.format(junit_path) if junit_path \
|
|
|
3539
|
+ else 'rerun them individually'
|
|
|
3540
|
+ file.write('Output of {} unexpected failures omitted (limit {}); {}.\n\n'
|
|
|
3541
|
+ .format(len(t.unexpected_failures), MAX_SUMMARY_OUTPUT_TESTS, where))
|
|
|
3542
|
+ else:
|
|
|
3543
|
+ file.write('Output of unexpected failures:\n\n')
|
|
|
3544
|
+ printTestOutputSummary(file, t.unexpected_failures, color, junit_path)
|
|
|
3545
|
+
|
|
3533
|
3546
|
printUnexpectedTests(file,
|
|
3534
|
3547
|
[t.unexpected_passes, t.unexpected_failures,
|
|
3535
|
3548
|
t.unexpected_stat_failures, t.framework_failures])
|
| ... |
... |
@@ -3596,10 +3609,6 @@ def summary(t: TestRun, file: TextIO, color=False) -> None: |
|
3596
|
3609
|
file.write('Framework warnings:\n')
|
|
3597
|
3610
|
printTestInfosSummary(file, t.framework_warnings)
|
|
3598
|
3611
|
|
|
3599
|
|
- if t.unexpected_failures:
|
|
3600
|
|
- file.write('Output of unexpected failures:\n\n')
|
|
3601
|
|
- printTestOutputSummary(file, t.unexpected_failures, color)
|
|
3602
|
|
-
|
|
3603
|
3612
|
if stopping():
|
|
3604
|
3613
|
file.write('WARNING: Testsuite run was terminated early\n')
|
|
3605
|
3614
|
|
| ... |
... |
@@ -3616,9 +3625,15 @@ def printUnexpectedTests(file: TextIO, testInfoss): |
|
3616
|
3625
|
# Per-stream cap on a failing test's output repeated in the final summary.
|
|
3617
|
3626
|
MAX_SUMMARY_OUTPUT_LINES = 100
|
|
3618
|
3627
|
|
|
3619
|
|
-def printTestOutputSummary(file: TextIO, testInfos, color: bool=False) -> None:
|
|
|
3628
|
+# Above this many unexpected failures, skip repeating output entirely: the
|
|
|
3629
|
+# dump would drown out the summary.
|
|
|
3630
|
+MAX_SUMMARY_OUTPUT_TESTS = 20
|
|
|
3631
|
+
|
|
|
3632
|
+def printTestOutputSummary(file: TextIO, testInfos, color: bool=False,
|
|
|
3633
|
+ junit_path: Optional[Path]=None) -> None:
|
|
3620
|
3634
|
# Repeat failing tests' captured output in the summary, so one needn't
|
|
3621
|
3635
|
# hunt for it earlier in a possibly very long log; see #16720.
|
|
|
3636
|
+ where = ', see {}'.format(junit_path) if junit_path else ''
|
|
3622
|
3637
|
for result in sorted(testInfos, key=lambda r: (r.testname.lower(), r.way, r.directory)):
|
|
3623
|
3638
|
header = '=====> {}({}) [{}]'.format(result.testname, result.way, result.reason)
|
|
3624
|
3639
|
if color:
|
| ... |
... |
@@ -3633,7 +3648,7 @@ def printTestOutputSummary(file: TextIO, testInfos, color: bool=False) -> None: |
|
3633
|
3648
|
if len(lines) > MAX_SUMMARY_OUTPUT_LINES:
|
|
3634
|
3649
|
omitted = len(lines) - MAX_SUMMARY_OUTPUT_LINES
|
|
3635
|
3650
|
lines = lines[:MAX_SUMMARY_OUTPUT_LINES] \
|
|
3636
|
|
- + ['... ({} more lines omitted, see junit.xml)'.format(omitted)]
|
|
|
3651
|
+ + ['... ({} more lines omitted{})'.format(omitted, where)]
|
|
3637
|
3652
|
s = label + '\n' + ''.join(l + '\n' for l in lines)
|
|
3638
|
3653
|
# Test output can contain characters that file's encoding
|
|
3639
|
3654
|
# cannot represent; replace rather than crash (cf safe_print).
|