Skip to content

Commit a643d3c

Browse files
jbergstroemMylesBorins
authored andcommitted
test: output tap13 instead of almost-tap
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent 7dc875c commit a643d3c

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

tools/test.py

+29-10
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,15 @@ def HasRun(self, output):
255255

256256
class TapProgressIndicator(SimpleProgressIndicator):
257257

258-
def _printDiagnostic(self, messages):
259-
for l in messages.splitlines():
260-
logger.info('# ' + l)
258+
def _printDiagnostic(self, traceback, severity):
259+
logger.info(' severity: %s', severity)
260+
logger.info(' stack: |-')
261+
262+
for l in traceback.splitlines():
263+
logger.info(' ' + l)
261264

262265
def Starting(self):
266+
logger.info('TAP version 13')
263267
logger.info('1..%i' % len(self.cases))
264268
self._done = 0
265269

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

269273
def HasRun(self, output):
270274
self._done += 1
275+
self.traceback = ''
276+
self.severity = 'ok'
271277

272278
# Print test name as (for example) "parallel/test-assert". Tests that are
273279
# scraped from the addons documentation are all named test.js, making it
@@ -280,19 +286,23 @@ def HasRun(self, output):
280286

281287
if output.UnexpectedOutput():
282288
status_line = 'not ok %i %s' % (self._done, command)
289+
self.severity = 'fail'
290+
self.traceback = output.output.stdout + output.output.stderr
291+
283292
if FLAKY in output.test.outcomes and self.flaky_tests_mode == DONTCARE:
284293
status_line = status_line + ' # TODO : Fix flaky test'
294+
self.severity = 'flaky'
295+
285296
logger.info(status_line)
286-
self._printDiagnostic("\n".join(output.diagnostic))
287297

288298
if output.HasCrashed():
289-
self._printDiagnostic(PrintCrashed(output.output.exit_code))
299+
self.severity = 'crashed'
300+
exit_code = output.output.exit_code
301+
self.traceback = "oh no!\nexit code: " + PrintCrashed(exit_code)
290302

291303
if output.HasTimedOut():
292-
self._printDiagnostic('TIMEOUT')
304+
self.severity = 'fail'
293305

294-
self._printDiagnostic(output.output.stderr)
295-
self._printDiagnostic(output.output.stdout)
296306
else:
297307
skip = skip_regex.search(output.output.stdout)
298308
if skip:
@@ -303,7 +313,11 @@ def HasRun(self, output):
303313
if FLAKY in output.test.outcomes:
304314
status_line = status_line + ' # TODO : Fix flaky test'
305315
logger.info(status_line)
306-
self._printDiagnostic("\n".join(output.diagnostic))
316+
317+
if output.diagnostic:
318+
self.severity = 'ok'
319+
self.traceback = output.diagnostic
320+
307321

308322
duration = output.test.duration
309323

@@ -314,7 +328,12 @@ def HasRun(self, output):
314328
# duration_ms is measured in seconds and is read as such by TAP parsers.
315329
# It should read as "duration including ms" rather than "duration in ms"
316330
logger.info(' ---')
317-
logger.info(' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000))
331+
logger.info(' duration_ms: %d.%d' %
332+
(total_seconds, duration.microseconds / 1000))
333+
if self.severity is not 'ok' or self.traceback is not '':
334+
if output.HasTimedOut():
335+
self.traceback = 'timeout'
336+
self._printDiagnostic(self.traceback, self.severity)
318337
logger.info(' ...')
319338

320339
def Done(self):

0 commit comments

Comments
 (0)