Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
gtest: output tap comments as yamlish
This makes yaml-ish parsers happy.
Note: gtest still seems to output the expected/result slightly
different making the full traceback less informational.

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 committed Nov 10, 2016
commit 6831ebe3bb03d9b366e7e22620251ab78871fc8f
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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