Skip to content

Commit

Permalink
gtest: output tap comments as yamlish
Browse files Browse the repository at this point in the history
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 authored and MylesBorins committed Nov 11, 2016
1 parent a643d3c commit 575fc4e
Showing 1 changed file with 9 additions and 7 deletions.
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) {
*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

0 comments on commit 575fc4e

Please sign in to comment.