diff --git a/tools/test.py b/tools/test.py index b543010990..05cd924344 100755 --- a/tools/test.py +++ b/tools/test.py @@ -255,11 +255,15 @@ class DotsProgressIndicator(SimpleProgressIndicator): class TapProgressIndicator(SimpleProgressIndicator): - def _printDiagnostic(self, messages): - for l in messages.splitlines(): - logger.info('# ' + l) + def _printDiagnostic(self, traceback, severity): + logger.info(' severity: %s', severity) + logger.info(' stack: |-') + + for l in traceback.splitlines(): + logger.info(' ' + l) def Starting(self): + logger.info('TAP version 13') logger.info('1..%i' % len(self.cases)) self._done = 0 @@ -268,6 +272,8 @@ class TapProgressIndicator(SimpleProgressIndicator): def HasRun(self, output): self._done += 1 + self.traceback = '' + self.severity = 'ok' # Print test name as (for example) "parallel/test-assert". Tests that are # scraped from the addons documentation are all named test.js, making it @@ -280,19 +286,23 @@ class TapProgressIndicator(SimpleProgressIndicator): if output.UnexpectedOutput(): status_line = 'not ok %i %s' % (self._done, command) + self.severity = 'fail' + self.traceback = output.output.stdout + output.output.stderr + if FLAKY in output.test.outcomes and self.flaky_tests_mode == DONTCARE: status_line = status_line + ' # TODO : Fix flaky test' + self.severity = 'flaky' + logger.info(status_line) - self._printDiagnostic("\n".join(output.diagnostic)) if output.HasCrashed(): - self._printDiagnostic(PrintCrashed(output.output.exit_code)) + self.severity = 'crashed' + exit_code = output.output.exit_code + self.traceback = "oh no!\nexit code: " + PrintCrashed(exit_code) if output.HasTimedOut(): - self._printDiagnostic('TIMEOUT') + self.severity = 'fail' - self._printDiagnostic(output.output.stderr) - self._printDiagnostic(output.output.stdout) else: skip = skip_regex.search(output.output.stdout) if skip: @@ -303,7 +313,11 @@ class TapProgressIndicator(SimpleProgressIndicator): if FLAKY in output.test.outcomes: status_line = status_line + ' # TODO : Fix flaky test' logger.info(status_line) - self._printDiagnostic("\n".join(output.diagnostic)) + + if output.diagnostic: + self.severity = 'ok' + self.traceback = output.diagnostic + duration = output.test.duration @@ -314,7 +328,12 @@ class TapProgressIndicator(SimpleProgressIndicator): # duration_ms is measured in seconds and is read as such by TAP parsers. # It should read as "duration including ms" rather than "duration in ms" logger.info(' ---') - logger.info(' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000)) + logger.info(' duration_ms: %d.%d' % + (total_seconds, duration.microseconds / 1000)) + if self.severity is not 'ok' or self.traceback is not '': + if output.HasTimedOut(): + self.traceback = 'timeout' + self._printDiagnostic(self.traceback, self.severity) logger.info(' ...') def Done(self):