@@ -130,6 +130,7 @@ grpc::Status TestRunner::runTests(bool withCoverage, const std::optional<std::ch
130130    MEASURE_FUNCTION_EXECUTION_TIME
131131    ExecUtils::throwIfCancelled ();
132132
133+     fs::remove (Paths::getGTestResultsJsonPath (projectContext));
133134    const  auto  buildRunCommands = coverageTool->getBuildRunCommands (testsToLaunch, withCoverage);
134135    ExecUtils::doWorkWithProgress (buildRunCommands, progressWriter, " Running tests" 
135136                              [this , testTimeout] (BuildRunCommand const  &buildRunCommand) {
@@ -195,37 +196,41 @@ testsgen::TestResultObject TestRunner::runTest(const BuildRunCommand &command, c
195196    auto  res = command.runCommand .run (projectContext.buildDir , true , true , testTimeout);
196197    GTestLogger::log (res.output );
197198
199+     testsgen::TestResultObject testRes;
200+     testRes.set_testfilepath (command.unitTest .testFilePath );
201+     testRes.set_testname (command.unitTest .testname );
198202    auto  executionTime = new  google::protobuf::Duration;
199-     if  (fs::exists (Paths::getGTestResultsJsonPath (projectContext))) {
200-         nlohmann::json gtestResultsJson = JsonUtils::getJsonFromFile (Paths::getGTestResultsJsonPath (projectContext));
201-         if  (!google::protobuf::util::TimeUtil::FromString (gtestResultsJson[" time" 
202-             LOG_S (WARNING) << " Cannot parse duration of test execution" 
203-         }
204-     } else  {
203+ 
204+     if  (BaseForkTask::wasInterrupted (res.status )) {
205+         testRes.set_status (testsgen::TEST_INTERRUPTED);
205206        if  (testTimeout.has_value ()) {
206207            *executionTime = google::protobuf::util::TimeUtil::SecondsToDuration (testTimeout.value ().count ());
207208        } else  {
208-             LOG_S (WARNING) << " Google test results are not generated, timeout not found" 
209+             LOG_S (WARNING) << StringUtils::stringFormat (" Test %s:%s execution was interrupted without timeout set" 
210+                                                         fs::relative (command.unitTest .testFilePath ,
211+                                                                      projectContext.projectPath ),
212+                                                         command.unitTest .testname );
209213        }
214+         testRes.set_allocated_executiontime (executionTime);
215+         return  testRes;
210216    }
211217
212-     testsgen::TestResultObject testRes;
213-     testRes.set_testfilepath (command.unitTest .testFilePath );
214-     testRes.set_testname (command.unitTest .testname );
215-     testRes.set_allocated_executiontime (executionTime);
216-     if  (StringUtils::contains (res.output , " [  PASSED  ] 1 test" 
217-         testRes.set_status (testsgen::TEST_PASSED);
218+     if  (!fs::exists (Paths::getGTestResultsJsonPath (projectContext))) {
219+         testRes.set_status (testsgen::TEST_DEATH);
218220        return  testRes;
219221    }
220-     if  (StringUtils::contains (res.output , " [  FAILED  ] 1 test" 
221-         testRes.set_status (testsgen::TEST_FAILED);
222-         return  testRes;
222+ 
223+     nlohmann::json gtestResultsJson = JsonUtils::getJsonFromFile (Paths::getGTestResultsJsonPath (projectContext));
224+     if  (!google::protobuf::util::TimeUtil::FromString (gtestResultsJson[" time" 
225+         LOG_S (WARNING) << " Cannot parse duration of test execution" 
223226    }
224-     if  (BaseForkTask::wasInterrupted (res.status )) {
225-         testRes.set_status (testsgen::TEST_INTERRUPTED);
226-         return  testRes;
227+     testRes.set_allocated_executiontime (executionTime);
228+     if  (gtestResultsJson[" failures" 0 ) {
229+         testRes.set_status (testsgen::TEST_FAILED);
230+     } else  {
231+         testRes.set_status (testsgen::TEST_PASSED);
227232    }
228-     testRes. set_status (testsgen::TEST_DEATH );
233+     fs::remove ( Paths::getGTestResultsJsonPath (projectContext) );
229234    return  testRes;
230235}
231236
0 commit comments