Commit d9337dc1 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[testrunner] Output unexpected passing tests

Passing tests that are marked as fail in a status file are not
immediately visible as such.

- Always show "--- FAILED ---" for failing tests
- Show "--- UNEXPECTED PASS ---" for unexpectedly passing tests

Drive-by-fixes:
- Color failures in red with --progress=color
- Color repro command in yellow with --progress=color

Change-Id: Id43ecec348dbfd4ff627ea6aa4ba458a2e5a8445
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2213434Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68131}
parent 01724ace
...@@ -160,6 +160,11 @@ class TestCase(object): ...@@ -160,6 +160,11 @@ class TestCase(object):
statusfile.FAIL in self._statusfile_outcomes and statusfile.FAIL in self._statusfile_outcomes and
statusfile.CRASH not in self._statusfile_outcomes) statusfile.CRASH not in self._statusfile_outcomes)
@property
def is_fail(self):
return (statusfile.FAIL in self._statusfile_outcomes and
statusfile.PASS not in self._statusfile_outcomes)
@property @property
def only_standard_variant(self): def only_standard_variant(self):
return statusfile.NO_VARIANTS in self._statusfile_outcomes return statusfile.NO_VARIANTS in self._statusfile_outcomes
......
...@@ -243,15 +243,22 @@ class CompactProgressIndicator(ProgressIndicator): ...@@ -243,15 +243,22 @@ class CompactProgressIndicator(ProgressIndicator):
self._clear_line(self._last_status_length) self._clear_line(self._last_status_length)
print_failure_header(test) print_failure_header(test)
if len(stdout): if len(stdout):
print(self._templates['stdout'] % stdout) self.printFormatted('stdout', stdout)
if len(stderr): if len(stderr):
print(self._templates['stderr'] % stderr) self.printFormatted('stderr', stderr)
print("Command: %s" % result.cmd.to_string(relative=True)) self.printFormatted(
'command', "Command: %s" % result.cmd.to_string(relative=True))
if output.HasCrashed(): if output.HasCrashed():
print("exit code: %s" % output.exit_code_string) self.printFormatted(
print("--- CRASHED ---") 'failure', "exit code: %s" % output.exit_code_string)
if output.HasTimedOut(): self.printFormatted('failure', "--- CRASHED ---")
print("--- TIMEOUT ---") elif output.HasTimedOut():
self.printFormatted('failure', "--- TIMEOUT ---")
else:
if test.is_fail:
self.printFormatted('failure', "--- UNEXPECTED PASS ---")
else:
self.printFormatted('failure', "--- FAILED ---")
def finished(self): def finished(self):
self._print_progress('Done') self._print_progress('Done')
...@@ -272,12 +279,12 @@ class CompactProgressIndicator(ProgressIndicator): ...@@ -272,12 +279,12 @@ class CompactProgressIndicator(ProgressIndicator):
'mins': int(elapsed) // 60, 'mins': int(elapsed) // 60,
'secs': int(elapsed) % 60 'secs': int(elapsed) % 60
} }
status = self._truncate(status, 78) status = self._truncateStatusLine(status, 78)
self._last_status_length = len(status) self._last_status_length = len(status)
print(status, end='') print(status, end='')
sys.stdout.flush() sys.stdout.flush()
def _truncate(self, string, length): def _truncateStatusLine(self, string, length):
if length and len(string) > (length - 3): if length and len(string) > (length - 3):
return string[:(length - 3)] + "..." return string[:(length - 3)] + "..."
else: else:
...@@ -296,22 +303,33 @@ class ColorProgressIndicator(CompactProgressIndicator): ...@@ -296,22 +303,33 @@ class ColorProgressIndicator(CompactProgressIndicator):
"\033[31m-%(failed) 4d\033[0m]: %(test)s"), "\033[31m-%(failed) 4d\033[0m]: %(test)s"),
'stdout': "\033[1m%s\033[0m", 'stdout': "\033[1m%s\033[0m",
'stderr': "\033[31m%s\033[0m", 'stderr': "\033[31m%s\033[0m",
'failure': "\033[1;31m%s\033[0m",
'command': "\033[33m%s\033[0m",
} }
super(ColorProgressIndicator, self).__init__(templates) super(ColorProgressIndicator, self).__init__(templates)
def printFormatted(self, format, string):
print(self._templates[format] % string)
def _truncateStatusLine(self, string, length):
# Add some slack for the color control chars
return super(ColorProgressIndicator, self)._truncateStatusLine(
string, length + 3*9)
def _clear_line(self, last_length): def _clear_line(self, last_length):
print("\033[1K\r", end='') print("\033[1K\r", end='')
class MonochromeProgressIndicator(CompactProgressIndicator): class MonochromeProgressIndicator(CompactProgressIndicator):
def __init__(self): def __init__(self):
templates = { templates = {
'status_line': ("[%(mins)02i:%(secs)02i|%%%(progress) 4d|" 'status_line': ("[%(mins)02i:%(secs)02i|%%%(progress) 4d|"
"+%(passed) 4d|-%(failed) 4d]: %(test)s"), "+%(passed) 4d|-%(failed) 4d]: %(test)s"),
'stdout': '%s', }
'stderr': '%s', super(MonochromeProgressIndicator, self).__init__(templates)
}
super(MonochromeProgressIndicator, self).__init__(templates) def printFormatted(self, format, string):
print(string)
def _clear_line(self, last_length): def _clear_line(self, last_length):
print(("\r" + (" " * last_length) + "\r"), end='') print(("\r" + (" " * last_length) + "\r"), end='')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment