Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(675)

Unified Diff: base/test/gtest_xml_unittest_result_printer.cc

Issue 2606153003: Report failed expect/assert to test launcher summary output. (Closed)
Patch Set: Always provide unencoded summary. Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/gtest_xml_unittest_result_printer.h ('k') | base/test/gtest_xml_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/gtest_xml_unittest_result_printer.cc
diff --git a/base/test/gtest_xml_unittest_result_printer.cc b/base/test/gtest_xml_unittest_result_printer.cc
index 192c228e2dd28a602dbe54f81dd4e28d487df40e..6ce4fdecf3fcddd2487f5e529e56f86d00f1a2e3 100644
--- a/base/test/gtest_xml_unittest_result_printer.cc
+++ b/base/test/gtest_xml_unittest_result_printer.cc
@@ -4,6 +4,7 @@
#include "base/test/gtest_xml_unittest_result_printer.h"
+#include "base/base64.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/time/time.h"
@@ -64,6 +65,9 @@ void XmlUnitTestResultPrinter::OnTestEnd(const testing::TestInfo& test_info) {
fprintf(output_file_,
" <failure message=\"\" type=\"\"></failure>\n");
}
+ for (int i = 0; i < test_info.result()->total_part_count(); ++i) {
+ WriteTestPartResult(test_info.result()->GetTestPartResult(i));
+ }
fprintf(output_file_, " </testcase>\n");
fflush(output_file_);
}
@@ -74,4 +78,34 @@ void XmlUnitTestResultPrinter::OnTestCaseEnd(
fflush(output_file_);
}
+void XmlUnitTestResultPrinter::WriteTestPartResult(
+ const testing::TestPartResult& test_part_result) {
+ const char* type = "unknown";
+ switch (test_part_result.type()) {
+ case testing::TestPartResult::kSuccess:
+ type = "success";
+ break;
+ case testing::TestPartResult::kNonFatalFailure:
+ type = "failure";
+ break;
+ case testing::TestPartResult::kFatalFailure:
+ type = "fatal_failure";
+ break;
+ }
+ std::string summary = test_part_result.summary();
+ std::string summary_encoded;
+ Base64Encode(summary, &summary_encoded);
+ std::string message = test_part_result.message();
+ std::string message_encoded;
+ Base64Encode(message, &message_encoded);
+ fprintf(output_file_,
+ " <x-test-result-part type=\"%s\" file=\"%s\" line=\"%d\">\n"
+ " <summary>%s</summary>\n"
+ " <message>%s</message>\n"
+ " </x-test-result-part>\n",
+ type, test_part_result.file_name(), test_part_result.line_number(),
+ summary_encoded.c_str(), message_encoded.c_str());
+ fflush(output_file_);
+}
+
} // namespace base
« no previous file with comments | « base/test/gtest_xml_unittest_result_printer.h ('k') | base/test/gtest_xml_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698