@@ -4743,26 +4743,53 @@ void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
47434743 const TestResult& result) {
47444744 const std::string kIndent = Indent (10 );
47454745
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 =
4759+ EscapeJson (location + " \n " + part.message ());
4760+ *stream << kIndent << " {\n "
4761+ << kIndent << " \" failure\" : \" " << message << " \" ,\n "
4762+ << kIndent << " \" type\" : \"\"\n "
4763+ << kIndent << " }" ;
4764+ }
4765+ }
4766+
4767+ if (failures > 0 ) *stream << " \n " << kIndent << " ]" ;
4768+ }
4769+
4770+ {
4771+ int skipped = 0 ;
4772+ for (int i = 0 ; i < result.total_part_count (); ++i) {
4773+ const TestPartResult& part = result.GetTestPartResult (i);
4774+ if (part.skipped ()) {
4775+ *stream << " ,\n " ;
4776+ if (++skipped == 1 ) {
4777+ *stream << kIndent << " \" " << " skipped" << " \" : [\n " ;
4778+ }
4779+ const std::string location =
4780+ internal::FormatCompilerIndependentFileLocation (part.file_name (),
4781+ part.line_number ());
4782+ const std::string message =
4783+ EscapeJson (location + " \n " + part.message ());
4784+ *stream << kIndent << " {\n "
4785+ << kIndent << " \" message\" : \" " << message << " \"\n "
4786+ << kIndent << " }" ;
47534787 }
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 << " }" ;
47624788 }
4789+
4790+ if (skipped > 0 ) *stream << " \n " << kIndent << " ]" ;
47634791 }
47644792
4765- if (failures > 0 ) *stream << " \n " << kIndent << " ]" ;
47664793 *stream << " \n " << Indent (8 ) << " }" ;
47674794}
47684795
0 commit comments