| ... |
... |
@@ -3543,7 +3543,8 @@ def summary(t: TestRun, file: TextIO, color=False) -> None: |
|
3543
|
3543
|
summary_color = Color.GREEN
|
|
3544
|
3544
|
|
|
3545
|
3545
|
assert t.start_time is not None
|
|
3546
|
|
- file.write(colored(summary_color, 'SUMMARY') + ' for test run started at '
|
|
|
3546
|
+ summary_header = colored(summary_color, 'SUMMARY') if color else 'SUMMARY'
|
|
|
3547
|
+ file.write(summary_header + ' for test run started at '
|
|
3547
|
3548
|
+ t.start_time.strftime("%c %Z") + '\n'
|
|
3548
|
3549
|
+ str(datetime.datetime.now() - t.start_time).rjust(8)
|
|
3549
|
3550
|
+ ' spent to go through\n'
|
| ... |
... |
@@ -3597,7 +3598,7 @@ def summary(t: TestRun, file: TextIO, color=False) -> None: |
|
3597
|
3598
|
|
|
3598
|
3599
|
if t.unexpected_failures:
|
|
3599
|
3600
|
file.write('Output of unexpected failures:\n\n')
|
|
3600
|
|
- printTestOutputSummary(file, t.unexpected_failures)
|
|
|
3601
|
+ printTestOutputSummary(file, t.unexpected_failures, color)
|
|
3601
|
3602
|
|
|
3602
|
3603
|
if stopping():
|
|
3603
|
3604
|
file.write('WARNING: Testsuite run was terminated early\n')
|
| ... |
... |
@@ -3615,26 +3616,34 @@ def printUnexpectedTests(file: TextIO, testInfoss): |
|
3615
|
3616
|
# Per-stream cap on a failing test's output repeated in the final summary.
|
|
3616
|
3617
|
MAX_SUMMARY_OUTPUT_LINES = 100
|
|
3617
|
3618
|
|
|
3618
|
|
-def printTestOutputSummary(file: TextIO, testInfos) -> None:
|
|
|
3619
|
+def printTestOutputSummary(file: TextIO, testInfos, color: bool=False) -> None:
|
|
3619
|
3620
|
# Repeat failing tests' captured output in the summary, so one needn't
|
|
3620
|
3621
|
# hunt for it earlier in a possibly very long log; see #16720.
|
|
3621
|
3622
|
for result in sorted(testInfos, key=lambda r: (r.testname.lower(), r.way, r.directory)):
|
|
3622
|
|
- file.write(colored(Color.RED,
|
|
3623
|
|
- '=====> {}({}) [{}]'.format(result.testname, result.way, result.reason))
|
|
3624
|
|
- + '\n')
|
|
|
3623
|
+ header = '=====> {}({}) [{}]'.format(result.testname, result.way, result.reason)
|
|
|
3624
|
+ if color:
|
|
|
3625
|
+ header = colored(Color.RED, header)
|
|
|
3626
|
+ file.write(header + '\n')
|
|
3625
|
3627
|
for stream_name, contents in [('stdout', result.stdout), ('stderr', result.stderr)]:
|
|
3626
|
3628
|
if contents and contents.strip():
|
|
|
3629
|
+ label = 'Captured {}:'.format(stream_name)
|
|
|
3630
|
+ if color:
|
|
|
3631
|
+ label = colored(Color.CYAN, label)
|
|
3627
|
3632
|
lines = contents.rstrip('\n').split('\n')
|
|
3628
|
3633
|
if len(lines) > MAX_SUMMARY_OUTPUT_LINES:
|
|
3629
|
3634
|
omitted = len(lines) - MAX_SUMMARY_OUTPUT_LINES
|
|
3630
|
3635
|
lines = lines[:MAX_SUMMARY_OUTPUT_LINES] \
|
|
3631
|
3636
|
+ ['... ({} more lines omitted, see junit.xml)'.format(omitted)]
|
|
3632
|
|
- s = 'Captured {}:\n{}\n'.format(stream_name, '\n'.join(lines))
|
|
|
3637
|
+ s = label + '\n' + ''.join(l + '\n' for l in lines)
|
|
3633
|
3638
|
# Test output can contain characters that file's encoding
|
|
3634
|
3639
|
# cannot represent; replace rather than crash (cf safe_print).
|
|
3635
|
3640
|
enc = getattr(file, 'encoding', None) or 'utf-8'
|
|
3636
|
3641
|
file.write(s.encode(enc, errors='replace').decode(enc))
|
|
3637
|
3642
|
file.write('\n')
|
|
|
3643
|
+ footer = '<===== end of output of unexpected failures'
|
|
|
3644
|
+ if color:
|
|
|
3645
|
+ footer = colored(Color.RED, footer)
|
|
|
3646
|
+ file.write(footer + '\n\n')
|
|
3638
|
3647
|
|
|
3639
|
3648
|
def printTestInfosSummary(file: TextIO, testInfos):
|
|
3640
|
3649
|
maxDirLen = max(len(tr.directory) for tr in testInfos)
|