Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test.py tap13 output #9262

Merged
merged 3 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ deps/npm/node_modules/.bin/
# test artifacts
tools/faketime
icu_config.gypi
test.tap
*.tap

# Xcode workspaces and project folders
*.xcodeproj
Expand Down
16 changes: 9 additions & 7 deletions deps/gtest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3596,25 +3596,27 @@ void TapUnitTestResultPrinter::OutputTapTestInfo(int* count,
*stream << " ---\n";
*stream << " duration_ms: " <<
FormatTimeInMillisAsSeconds(result.elapsed_time()) << "\n";
*stream << " ...\n";

for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
OutputTapComment(stream, part.message());
if (result.total_part_count() > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if statement doesn't look like it's necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it there to avoid writing "stack" unless used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I misread the diff that won't happen because it's inside the loop. If result.total_part_count() == 0 then i < result.total_part_count() with i == 0 is false so it's not reached.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I messed up -- moved stuff around too quick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps should mention that i've fixed it since.

*stream << " stack: |-\n";
for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
OutputTapComment(stream, part.message());
}
}

*stream << " ...\n";
*count += 1;
}

void TapUnitTestResultPrinter::OutputTapComment(::std::ostream* stream,
const char* comment) {
const char* start = comment;
while (const char* end = strchr(start, '\n')) {
*stream << "# " << std::string(start, end) << "\n";
*stream << " " << std::string(start, end) << "\n";
start = end + 1;
}
if (*start)
*stream << "# " << start << "\n";
*stream << " " << start << "\n";
}

// Formats the given time in milliseconds as seconds.
Expand Down
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 @@ -315,7 +329,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