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: nodejs#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 mscdex committed Nov 18, 2016
1 parent 7f81919 commit d2693b1
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 @@ -256,11 +256,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 @@ -269,6 +273,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 @@ -281,19 +287,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 @@ -304,7 +314,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 @@ -313,7 +327,12 @@ def HasRun(self, output):
(duration.seconds + duration.days * 24 * 3600) * 10**6) / 10**6

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 d2693b1

Please sign in to comment.