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

Side by Side 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, 11 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/gtest_xml_unittest_result_printer.h" 5 #include "base/test/gtest_xml_unittest_result_printer.h"
6 6
7 #include "base/base64.h"
7 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 XmlUnitTestResultPrinter::XmlUnitTestResultPrinter() : output_file_(NULL) { 14 XmlUnitTestResultPrinter::XmlUnitTestResultPrinter() : output_file_(NULL) {
14 } 15 }
15 16
16 XmlUnitTestResultPrinter::~XmlUnitTestResultPrinter() { 17 XmlUnitTestResultPrinter::~XmlUnitTestResultPrinter() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 " <testcase name=\"%s\" status=\"run\" time=\"%.3f\"" 58 " <testcase name=\"%s\" status=\"run\" time=\"%.3f\""
58 " classname=\"%s\">\n", 59 " classname=\"%s\">\n",
59 test_info.name(), 60 test_info.name(),
60 static_cast<double>(test_info.result()->elapsed_time()) / 61 static_cast<double>(test_info.result()->elapsed_time()) /
61 Time::kMillisecondsPerSecond, 62 Time::kMillisecondsPerSecond,
62 test_info.test_case_name()); 63 test_info.test_case_name());
63 if (test_info.result()->Failed()) { 64 if (test_info.result()->Failed()) {
64 fprintf(output_file_, 65 fprintf(output_file_,
65 " <failure message=\"\" type=\"\"></failure>\n"); 66 " <failure message=\"\" type=\"\"></failure>\n");
66 } 67 }
68 for (int i = 0; i < test_info.result()->total_part_count(); ++i) {
69 WriteTestPartResult(test_info.result()->GetTestPartResult(i));
70 }
67 fprintf(output_file_, " </testcase>\n"); 71 fprintf(output_file_, " </testcase>\n");
68 fflush(output_file_); 72 fflush(output_file_);
69 } 73 }
70 74
71 void XmlUnitTestResultPrinter::OnTestCaseEnd( 75 void XmlUnitTestResultPrinter::OnTestCaseEnd(
72 const testing::TestCase& test_case) { 76 const testing::TestCase& test_case) {
73 fprintf(output_file_, " </testsuite>\n"); 77 fprintf(output_file_, " </testsuite>\n");
74 fflush(output_file_); 78 fflush(output_file_);
75 } 79 }
76 80
81 void XmlUnitTestResultPrinter::WriteTestPartResult(
82 const testing::TestPartResult& test_part_result) {
83 const char* type = "unknown";
84 switch (test_part_result.type()) {
85 case testing::TestPartResult::kSuccess:
86 type = "success";
87 break;
88 case testing::TestPartResult::kNonFatalFailure:
89 type = "failure";
90 break;
91 case testing::TestPartResult::kFatalFailure:
92 type = "fatal_failure";
93 break;
94 }
95 std::string summary = test_part_result.summary();
96 std::string summary_encoded;
97 Base64Encode(summary, &summary_encoded);
98 std::string message = test_part_result.message();
99 std::string message_encoded;
100 Base64Encode(message, &message_encoded);
101 fprintf(output_file_,
102 " <x-test-result-part type=\"%s\" file=\"%s\" line=\"%d\">\n"
103 " <summary>%s</summary>\n"
104 " <message>%s</message>\n"
105 " </x-test-result-part>\n",
106 type, test_part_result.file_name(), test_part_result.line_number(),
107 summary_encoded.c_str(), message_encoded.c_str());
108 fflush(output_file_);
109 }
110
77 } // namespace base 111 } // namespace base
OLDNEW
« 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