@@ -953,6 +953,63 @@ namespace
953953 return value;
954954 }
955955
956+ static bool is_test_runner_noise_line (const std::string &line)
957+ {
958+ const std::string trimmed = trim_copy (line);
959+
960+ if (trimmed.empty ())
961+ return true ;
962+
963+ if (trimmed.rfind (" Running main() from " , 0 ) == 0 )
964+ return true ;
965+
966+ if (trimmed.rfind (" Note: Google Test filter =" , 0 ) == 0 )
967+ return true ;
968+
969+ if (trimmed.rfind (" [==========]" , 0 ) == 0 ||
970+ trimmed.rfind (" [----------]" , 0 ) == 0 ||
971+ trimmed.rfind (" [ RUN ]" , 0 ) == 0 ||
972+ trimmed.rfind (" [ OK ]" , 0 ) == 0 ||
973+ trimmed.rfind (" [ PASSED ]" , 0 ) == 0 ||
974+ trimmed.rfind (" [ FAILED ]" , 0 ) == 0 )
975+ {
976+ return true ;
977+ }
978+
979+ return false ;
980+ }
981+
982+ static bool looks_like_useful_failure_detail (const std::string &line)
983+ {
984+ const std::string trimmed = trim_copy (line);
985+
986+ if (trimmed.empty ())
987+ return false ;
988+
989+ if (trimmed.rfind (" Expected:" , 0 ) == 0 )
990+ return true ;
991+
992+ if (trimmed.rfind (" Actual:" , 0 ) == 0 )
993+ return true ;
994+
995+ if (trimmed.rfind (" Value of:" , 0 ) == 0 )
996+ return true ;
997+
998+ if (trimmed.rfind (" Which is:" , 0 ) == 0 )
999+ return true ;
1000+
1001+ if (trimmed.rfind (" Expected equality of these values:" , 0 ) == 0 )
1002+ return true ;
1003+
1004+ if (trimmed.find (" Assertion" ) != std::string::npos &&
1005+ trimmed.find (" failed" ) != std::string::npos)
1006+ {
1007+ return true ;
1008+ }
1009+
1010+ return false ;
1011+ }
1012+
9561013 static std::string extract_ctest_duration (const std::string &line)
9571014 {
9581015 const std::string marker = " sec" ;
@@ -1317,38 +1374,38 @@ namespace
13171374
13181375 failure.column = 1 ;
13191376
1320- std::string valueOf;
1321- std::string actual;
1322- std::string expected;
1377+ std::string message;
1378+ bool started = false ;
13231379
1324- for (std::size_t i = index + 1 ; i < lines.size () && i < index + 8 ; ++i)
1380+ for (std::size_t i = index + 1 ; i < lines.size () && i < index + 12 ; ++i)
13251381 {
13261382 const std::string current = trim_copy (lines[i]);
13271383
1328- if (current.rfind (" Value of:" , 0 ) == 0 )
1329- valueOf = trim_copy (current.substr (std::string (" Value of:" ).size ()));
1384+ if (current.rfind (" [ FAILED ]" , 0 ) == 0 ||
1385+ current.rfind (" [ RUN ]" , 0 ) == 0 ||
1386+ current.rfind (" [ OK ]" , 0 ) == 0 )
1387+ {
1388+ break ;
1389+ }
1390+
1391+ if (is_test_runner_noise_line (current))
1392+ continue ;
13301393
1331- else if (current. rfind ( " Actual: " , 0 ) == 0 )
1332- actual = trim_copy (current. substr ( std::string ( " Actual: " ). size ())) ;
1394+ if (!started && ! looks_like_useful_failure_detail (current) )
1395+ continue ;
13331396
1334- else if (current.rfind (" Expected:" , 0 ) == 0 )
1335- expected = trim_copy (current.substr (std::string (" Expected:" ).size ()));
1397+ started = true ;
13361398
1337- else if (current.rfind (" [ FAILED ]" , 0 ) == 0 ||
1338- current.rfind (" [ RUN ]" , 0 ) == 0 )
1339- break ;
1399+ if (!message.empty ())
1400+ message += " \n " ;
1401+
1402+ message += current;
13401403 }
13411404
1342- if (!valueOf .empty ())
1405+ if (!message .empty ())
13431406 {
1344- failure.assertion = valueOf;
1345- failure.message = " expected `" + valueOf + " ` to be true" ;
1346-
1347- if (!actual.empty ())
1348- failure.message += " \n actual: " + actual;
1349-
1350- if (!expected.empty ())
1351- failure.message += " \n expected: " + expected;
1407+ failure.assertion = message;
1408+ failure.message = message;
13521409 }
13531410 }
13541411
@@ -1391,15 +1448,9 @@ namespace
13911448
13921449 if (failure.has_assertion ())
13931450 {
1394- if (failure.message .find (" actual:" ) != std::string::npos ||
1395- failure.message .find (" expected:" ) != std::string::npos)
1396- {
1397- diagnostic.error = failure.message ;
1398- }
1399- else
1400- {
1401- diagnostic.error = " assertion failed: " + failure.assertion ;
1402- }
1451+ diagnostic.error = failure.message .empty ()
1452+ ? failure.assertion
1453+ : failure.message ;
14031454 }
14041455 else if (!failure.message .empty ())
14051456 {
0 commit comments