@@ -4743,26 +4743,51 @@ 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 = 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 << " }" ;
47534785 }
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 << " }" ;
47624786 }
4787+
4788+ if (skipped > 0 ) *stream << " \n " << kIndent << " ]" ;
47634789 }
47644790
4765- if (failures > 0 ) *stream << " \n " << kIndent << " ]" ;
47664791 *stream << " \n " << Indent (8 ) << " }" ;
47674792}
47684793
0 commit comments