From c3f145ca2b9f5a4cfac3ffe1de7d901a4e8aba10 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 15 Feb 2022 09:51:50 +0100 Subject: mtest: print stderr of TAP/Rust tests in verbose/non-parallel mode Verbose, non-parallel tests generally print their output as they run, rather than after they finish. This however is not the case if stdout of the test is parsed as is the case for TAP and Rust tests. In this case, the output during the run is the list of the subtests, but stderr still has to be printed after the test finishes. --- mesonbuild/mtest.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 4488a8c..8208132 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -665,9 +665,8 @@ class ConsoleLogger(TestLogger): if not harness.options.quiet or not result.res.is_ok(): self.flush() - if result.verbose and not result.is_parallel and result.cmdline: - if not result.needs_parsing: - print(self.output_end) + if result.verbose and not result.is_parallel and result.cmdline and not result.needs_parsing: + print(self.output_end) print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width)) else: print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width), -- cgit v1.1 From 02b739feae4ac31ebe83649da0e73296304cbb5c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 20 Feb 2022 14:08:37 +0100 Subject: mtest: refactor common condition into a property of TestRun For a test to be displayed to stdout without buffering, it has to be 1) in verbose mode 2) not executed in parallel with others 3) not parsed, i.e. not TAP or Rust. Include these three conditions in a new property of stdout and use it in the three places where it matters: when printing the initial and final delimiters of the output, and when deciding the console mode to use. Suggested-by: Jussi Pakkanen Signed-off-by: Paolo Bonzini --- mesonbuild/mtest.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 8208132..c844645 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -606,11 +606,9 @@ class ConsoleLogger(TestLogger): max_left_width=self.max_left_width, right=test.res.get_text(mlog.colorize_console()))) print(test.res.get_command_marker() + test.cmdline) - if test.needs_parsing: - pass - elif not test.is_parallel: + if test.direct_stdout: print(self.output_start, flush=True) - else: + elif not test.needs_parsing: print(flush=True) self.started_tests += 1 @@ -665,7 +663,7 @@ class ConsoleLogger(TestLogger): if not harness.options.quiet or not result.res.is_ok(): self.flush() - if result.verbose and not result.is_parallel and result.cmdline and not result.needs_parsing: + if result.cmdline and result.direct_stdout: print(self.output_end) print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width)) else: @@ -899,6 +897,10 @@ class TestRun: return self._num @property + def direct_stdout(self) -> bool: + return self.verbose and not self.is_parallel and not self.needs_parsing + + @property def detail(self) -> str: if self.res is TestResult.PENDING: return '' @@ -1340,7 +1342,7 @@ class SingleTestRunner: if self.options.gdb: self.console_mode = ConsoleUser.GDB - elif self.runobj.verbose and not is_parallel and not self.runobj.needs_parsing: + elif self.runobj.direct_stdout: self.console_mode = ConsoleUser.STDOUT else: self.console_mode = ConsoleUser.LOGGER -- cgit v1.1