mtest: log test start in verbose mode

In non-parallel verbose mode the output of the test/benchmark
is not buffered, therefore the command line is only printed by
ConsoleLogger for failing tests and only after the test has run.

Verbose mode is designed mostly for CI systems, where output must
be human readable but is generally consumed from a browser with "Find"
commands rather than from a terminal.  With this usecase in mind, it
is better to provide as much detail as possible, so add more output
and just tell the user which tests have started.  Do so, using the
recently introduced TestResult.RUNNING state.
pull/8200/head
Paolo Bonzini 4 years ago
parent 959e4b3a5e
commit 4d6a0cc174
  1. 50
      mesonbuild/mtest.py

@ -240,6 +240,9 @@ class TestResult(enum.Enum):
return self in {TestResult.FAIL, TestResult.TIMEOUT, TestResult.INTERRUPT, return self in {TestResult.FAIL, TestResult.TIMEOUT, TestResult.INTERRUPT,
TestResult.UNEXPECTEDPASS, TestResult.ERROR} TestResult.UNEXPECTEDPASS, TestResult.ERROR}
def is_finished(self) -> bool:
return self not in {TestResult.PENDING, TestResult.RUNNING}
def was_killed(self) -> bool: def was_killed(self) -> bool:
return self in (TestResult.TIMEOUT, TestResult.INTERRUPT) return self in (TestResult.TIMEOUT, TestResult.INTERRUPT)
@ -248,8 +251,10 @@ class TestResult(enum.Enum):
decorator = mlog.red decorator = mlog.red
elif self in (TestResult.SKIP, TestResult.EXPECTEDFAIL): elif self in (TestResult.SKIP, TestResult.EXPECTEDFAIL):
decorator = mlog.yellow decorator = mlog.yellow
else: elif self.is_finished():
decorator = mlog.green decorator = mlog.green
else:
decorator = mlog.blue
return decorator(s) return decorator(s)
def get_text(self, colorize: bool) -> str: def get_text(self, colorize: bool) -> str:
@ -579,6 +584,17 @@ class ConsoleLogger(TestLogger):
self.progress_task = asyncio.ensure_future(report_progress()) self.progress_task = asyncio.ensure_future(report_progress())
def start_test(self, harness: 'TestHarness', test: 'TestRun') -> None: def start_test(self, harness: 'TestHarness', test: 'TestRun') -> None:
if harness.options.verbose and test.cmdline:
self.flush()
print(harness.format(test, mlog.colorize_console(),
max_left_width=self.max_left_width,
right=test.res.get_text(mlog.colorize_console())))
print(test.res.get_command_marker() + test.cmdline)
if harness.options.num_processes == 1:
print(self.output_start, flush=True)
else:
print(flush=True)
self.started_tests += 1 self.started_tests += 1
self.running_tests.add(test) self.running_tests.add(test)
self.running_tests.move_to_end(test, last=False) self.running_tests.move_to_end(test, last=False)
@ -592,12 +608,14 @@ class ConsoleLogger(TestLogger):
else: else:
return str(mlog.bold('Listing only the last 100 lines from a long log.\n')) + '\n'.join(lines[-100:]) return str(mlog.bold('Listing only the last 100 lines from a long log.\n')) + '\n'.join(lines[-100:])
def print_log(self, result: 'TestRun', log: str) -> None: def print_log(self, harness: 'TestHarness', result: 'TestRun', log: str) -> None:
cmdline = result.cmdline if not harness.options.verbose:
if not cmdline: cmdline = result.cmdline
print(result.res.get_command_marker() + result.stdo) if not cmdline:
return print(result.res.get_command_marker() + result.stdo)
print(result.res.get_command_marker() + cmdline) return
print(result.res.get_command_marker() + cmdline)
if log: if log:
print(self.output_start) print(self.output_start)
print_safe(log, end='') print_safe(log, end='')
@ -612,12 +630,18 @@ class ConsoleLogger(TestLogger):
if not harness.options.quiet or not result.res.is_ok(): if not harness.options.quiet or not result.res.is_ok():
self.flush() self.flush()
print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width), if harness.options.verbose and harness.options.num_processes == 1 and result.cmdline:
flush=True) print(self.output_end)
if harness.options.verbose and harness.options.num_processes > 1: print(harness.format(result, mlog.colorize_console(), max_left_width=self.max_left_width))
self.print_log(result, result.get_log(mlog.colorize_console())) print(flush=True)
elif result.res.is_bad(): else:
self.print_log(result, '') 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, '')
self.request_update() self.request_update()
async def finish(self, harness: 'TestHarness') -> None: async def finish(self, harness: 'TestHarness') -> None:

Loading…
Cancel
Save