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

Side by Side Diff: base/test/gtest_xml_unittest_result_printer.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Add comment. Fix missed usage of SetLogAssertHandler. Created 3 years, 10 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
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/base64.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 17 matching lines...) Expand all
28 if (!output_file_) 28 if (!output_file_)
29 return false; 29 return false;
30 30
31 fprintf(output_file_, 31 fprintf(output_file_,
32 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites>\n"); 32 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites>\n");
33 fflush(output_file_); 33 fflush(output_file_);
34 34
35 return true; 35 return true;
36 } 36 }
37 37
38 void XmlUnitTestResultPrinter::OnAssert(const char* file,
39 int line,
40 const std::string& summary,
41 const std::string& message) {
42 if (output_file_) {
Paweł Hajdan Jr. 2017/01/27 17:19:44 nit: Please reverse condition, do early return, an
alex-ac 2017/02/11 20:12:19 Done.
43 std::string encoded_summary;
44 Base64Encode(summary, &encoded_summary);
45 std::string encoded_message;
46 Base64Encode(message, &encoded_message);
47 fprintf(output_file_,
48 " <x-test-result-part type=\"fatal_failure\" "
49 "file=\"%s\" line=\"%d\">\n"
50 " <summary>%s</summary>\n"
51 " <message>%s</message>\n"
52 " </x-test-result-part>",
53 file, line, encoded_summary.c_str(), encoded_message.c_str());
54 fflush(output_file_);
55 }
56 }
57
38 void XmlUnitTestResultPrinter::OnTestCaseStart( 58 void XmlUnitTestResultPrinter::OnTestCaseStart(
39 const testing::TestCase& test_case) { 59 const testing::TestCase& test_case) {
40 fprintf(output_file_, " <testsuite>\n"); 60 fprintf(output_file_, " <testsuite>\n");
41 fflush(output_file_); 61 fflush(output_file_);
42 } 62 }
43 63
44 void XmlUnitTestResultPrinter::OnTestStart( 64 void XmlUnitTestResultPrinter::OnTestStart(
45 const testing::TestInfo& test_info) { 65 const testing::TestInfo& test_info) {
46 // This is our custom extension - it helps to recognize which test was 66 // This is our custom extension - it helps to recognize which test was
47 // running when the test binary crashed. Note that we cannot even open the 67 // running when the test binary crashed. Note that we cannot even open the
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 " <x-test-result-part type=\"%s\" file=\"%s\" line=\"%d\">\n" 122 " <x-test-result-part type=\"%s\" file=\"%s\" line=\"%d\">\n"
103 " <summary>%s</summary>\n" 123 " <summary>%s</summary>\n"
104 " <message>%s</message>\n" 124 " <message>%s</message>\n"
105 " </x-test-result-part>\n", 125 " </x-test-result-part>\n",
106 type, test_part_result.file_name(), test_part_result.line_number(), 126 type, test_part_result.file_name(), test_part_result.line_number(),
107 summary_encoded.c_str(), message_encoded.c_str()); 127 summary_encoded.c_str(), message_encoded.c_str());
108 fflush(output_file_); 128 fflush(output_file_);
109 } 129 }
110 130
111 } // namespace base 131 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698