Skip to content

Commit

Permalink
test: output tap13 instead of almost-tap
Browse files Browse the repository at this point in the history
Produce a tap13-compatible output which makes it
simpler to parse. Output is still readable by
the jenkins tap plugin.

PR-URL: #9262
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
jbergstroem authored and MylesBorins committed Nov 11, 2016
1 parent 7dc875c commit a643d3c
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,15 @@ def HasRun(self, output):

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

Expand All @@ -268,6 +272,8 @@ def AboutToRun(self, case):

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
Expand All @@ -280,19 +286,23 @@ def HasRun(self, output):

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:
Expand All @@ -303,7 +313,11 @@ def HasRun(self, output):
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

Expand All @@ -314,7 +328,12 @@ def HasRun(self, output):
# 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):
Expand Down

0 comments on commit a643d3c

Please sign in to comment.