@@ -4743,26 +4743,51 @@ void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
4743
4743
const TestResult& result) {
4744
4744
const std::string kIndent = Indent (10 );
4745
4745
4746
- int failures = 0 ;
4747
- for (int i = 0 ; i < result.total_part_count (); ++i) {
4748
- const TestPartResult& part = result.GetTestPartResult (i);
4749
- if (part.failed ()) {
4750
- *stream << " ,\n " ;
4751
- if (++failures == 1 ) {
4752
- *stream << kIndent << " \" " << " failures" << " \" : [\n " ;
4746
+ {
4747
+ int failures = 0 ;
4748
+ for (int i = 0 ; i < result.total_part_count (); ++i) {
4749
+ const TestPartResult& part = result.GetTestPartResult (i);
4750
+ if (part.failed ()) {
4751
+ *stream << " ,\n " ;
4752
+ if (++failures == 1 ) {
4753
+ *stream << kIndent << " \" " << " failures" << " \" : [\n " ;
4754
+ }
4755
+ const std::string location =
4756
+ internal::FormatCompilerIndependentFileLocation (part.file_name (),
4757
+ part.line_number ());
4758
+ const std::string message = EscapeJson (location + " \n " + part.message ());
4759
+ *stream << kIndent << " {\n "
4760
+ << kIndent << " \" failure\" : \" " << message << " \" ,\n "
4761
+ << kIndent << " \" type\" : \"\"\n "
4762
+ << kIndent << " }" ;
4763
+ }
4764
+ }
4765
+
4766
+ if (failures > 0 ) *stream << " \n " << kIndent << " ]" ;
4767
+ }
4768
+
4769
+ {
4770
+ int skipped = 0 ;
4771
+ for (int i = 0 ; i < result.total_part_count (); ++i) {
4772
+ const TestPartResult& part = result.GetTestPartResult (i);
4773
+ if (part.skipped ()) {
4774
+ *stream << " ,\n " ;
4775
+ if (++skipped == 1 ) {
4776
+ *stream << kIndent << " \" " << " skipped" << " \" : [\n " ;
4777
+ }
4778
+ const std::string location =
4779
+ internal::FormatCompilerIndependentFileLocation (part.file_name (),
4780
+ part.line_number ());
4781
+ const std::string message = EscapeJson (location + " \n " + part.message ());
4782
+ *stream << kIndent << " {\n "
4783
+ << kIndent << " \" message\" : \" " << message << " \"\n "
4784
+ << kIndent << " }" ;
4753
4785
}
4754
- const std::string location =
4755
- internal::FormatCompilerIndependentFileLocation (part.file_name (),
4756
- part.line_number ());
4757
- const std::string message = EscapeJson (location + " \n " + part.message ());
4758
- *stream << kIndent << " {\n "
4759
- << kIndent << " \" failure\" : \" " << message << " \" ,\n "
4760
- << kIndent << " \" type\" : \"\"\n "
4761
- << kIndent << " }" ;
4762
4786
}
4787
+
4788
+ if (skipped > 0 ) *stream << " \n " << kIndent << " ]" ;
4763
4789
}
4764
4790
4765
- if (failures > 0 ) *stream << " \n " << kIndent << " ]" ;
4766
4791
*stream << " \n " << Indent (8 ) << " }" ;
4767
4792
}
4768
4793
0 commit comments