@@ -130,6 +130,7 @@ grpc::Status TestRunner::runTests(bool withCoverage, const std::optional<std::ch
130
130
MEASURE_FUNCTION_EXECUTION_TIME
131
131
ExecUtils::throwIfCancelled ();
132
132
133
+ fs::remove (Paths::getGTestResultsJsonPath (projectContext));
133
134
const auto buildRunCommands = coverageTool->getBuildRunCommands (testsToLaunch, withCoverage);
134
135
ExecUtils::doWorkWithProgress (buildRunCommands, progressWriter, " Running tests" ,
135
136
[this , testTimeout] (BuildRunCommand const &buildRunCommand) {
@@ -195,37 +196,41 @@ testsgen::TestResultObject TestRunner::runTest(const BuildRunCommand &command, c
195
196
auto res = command.runCommand .run (projectContext.buildDir , true , true , testTimeout);
196
197
GTestLogger::log (res.output );
197
198
199
+ testsgen::TestResultObject testRes;
200
+ testRes.set_testfilepath (command.unitTest .testFilePath );
201
+ testRes.set_testname (command.unitTest .testname );
198
202
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" ], executionTime)) {
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);
205
206
if (testTimeout.has_value ()) {
206
207
*executionTime = google::protobuf::util::TimeUtil::SecondsToDuration (testTimeout.value ().count ());
207
208
} 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 );
209
213
}
214
+ testRes.set_allocated_executiontime (executionTime);
215
+ return testRes;
210
216
}
211
217
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);
218
220
return testRes;
219
221
}
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" ], executionTime)) {
225
+ LOG_S (WARNING) << " Cannot parse duration of test execution" ;
223
226
}
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);
227
232
}
228
- testRes. set_status (testsgen::TEST_DEATH );
233
+ fs::remove ( Paths::getGTestResultsJsonPath (projectContext) );
229
234
return testRes;
230
235
}
231
236
0 commit comments