diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-01-22 09:47:33 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-01-22 12:18:59 +0100 |
commit | bb9d8b5b80e5f4aa421b4ad549d71fd103f2b1dc (patch) | |
tree | bb3f10f05fff556bbde567683e29098890e053f3 /mesonbuild/mtest.py | |
parent | 4d6a0cc174c7374f398f33f56353334036c499b7 (diff) | |
download | meson-bb9d8b5b80e5f4aa421b4ad549d71fd103f2b1dc.zip meson-bb9d8b5b80e5f4aa421b4ad549d71fd103f2b1dc.tar.gz meson-bb9d8b5b80e5f4aa421b4ad549d71fd103f2b1dc.tar.bz2 |
mtest: move --print-errorlogs output during the test run
Print the (shortened) output of the failed tests as they happen.
If neither --verbose nor --print-errorlogs was specified, omit the
summary of failures, because it is pretty much the same as the earlier
output of "meson test".
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r-- | mesonbuild/mtest.py | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 657f284..494be8b 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -600,15 +600,21 @@ class ConsoleLogger(TestLogger): self.running_tests.move_to_end(test, last=False) self.request_update() - def shorten_log(self, result: 'TestRun') -> str: + def shorten_log(self, harness: 'TestHarness', result: 'TestRun') -> str: + if not harness.options.verbose and not harness.options.print_errorlogs: + return '' + log = result.get_log(mlog.colorize_console()) + if harness.options.verbose: + return log + lines = log.splitlines() if len(lines) < 100: return log else: return str(mlog.bold('Listing only the last 100 lines from a long log.\n')) + '\n'.join(lines[-100:]) - def print_log(self, harness: 'TestHarness', result: 'TestRun', log: str) -> None: + def print_log(self, harness: 'TestHarness', result: 'TestRun') -> None: if not harness.options.verbose: cmdline = result.cmdline if not cmdline: @@ -616,6 +622,7 @@ class ConsoleLogger(TestLogger): return print(result.res.get_command_marker() + cmdline) + log = self.shorten_log(harness, result) if log: print(self.output_start) print_safe(log, end='') @@ -637,10 +644,8 @@ class ConsoleLogger(TestLogger): else: print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width), flush=True) - if harness.options.verbose: - self.print_log(harness, result, result.get_log(mlog.colorize_console())) - elif result.res.is_bad(): - self.print_log(harness, result, '') + if harness.options.verbose or result.res.is_bad(): + self.print_log(harness, result) self.request_update() @@ -650,18 +655,8 @@ class ConsoleLogger(TestLogger): if self.progress_task: await self.progress_task - if harness.collected_failures: - if harness.options.print_errorlogs: - if len(harness.collected_failures) > 10: - print('\n\nThe output from 10 first failed tests:\n') - else: - print('\n\nThe output from the failed tests:\n') - for i, result in enumerate(harness.collected_failures, 1): - print(harness.format(result, mlog.colorize_console())) - self.print_log(result, self.shorten_log(result)) - if i == 10: - break - + if harness.collected_failures and \ + (harness.options.print_errorlogs or harness.options.verbose): print("\nSummary of Failures:\n") for i, result in enumerate(harness.collected_failures, 1): print(harness.format(result, mlog.colorize_console())) |