@@ -195,37 +195,41 @@ testsgen::TestResultObject TestRunner::runTest(const BuildRunCommand &command, c
195
195
auto res = command.runCommand .run (projectContext.buildDir , true , true , testTimeout);
196
196
GTestLogger::log (res.output );
197
197
198
+ testsgen::TestResultObject testRes;
199
+ testRes.set_testfilepath (command.unitTest .testFilePath );
200
+ testRes.set_testname (command.unitTest .testname );
198
201
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 {
202
+
203
+ if (BaseForkTask::wasInterrupted (res.status )) {
204
+ testRes.set_status (testsgen::TEST_INTERRUPTED);
205
205
if (testTimeout.has_value ()) {
206
206
*executionTime = google::protobuf::util::TimeUtil::SecondsToDuration (testTimeout.value ().count ());
207
207
} else {
208
- LOG_S (WARNING) << " Google test results are not generated, timeout not found" ;
208
+ LOG_S (WARNING) << StringUtils::stringFormat (" Test %s:%s execution was interrupted without timeout set" ,
209
+ fs::relative (command.unitTest .testFilePath ,
210
+ projectContext.projectPath ),
211
+ command.unitTest .testname );
209
212
}
213
+ testRes.set_allocated_executiontime (executionTime);
214
+ return testRes;
210
215
}
211
216
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);
217
+ if (!fs::exists (Paths::getGTestResultsJsonPath (projectContext))) {
218
+ testRes.set_status (testsgen::TEST_DEATH);
218
219
return testRes;
219
220
}
220
- if (StringUtils::contains (res.output , " [ FAILED ] 1 test" )) {
221
- testRes.set_status (testsgen::TEST_FAILED);
222
- return testRes;
221
+
222
+ nlohmann::json gtestResultsJson = JsonUtils::getJsonFromFile (Paths::getGTestResultsJsonPath (projectContext));
223
+ if (!google::protobuf::util::TimeUtil::FromString (gtestResultsJson[" time" ], executionTime)) {
224
+ LOG_S (WARNING) << " Cannot parse duration of test execution" ;
223
225
}
224
- if (BaseForkTask::wasInterrupted (res.status )) {
225
- testRes.set_status (testsgen::TEST_INTERRUPTED);
226
- return testRes;
226
+ testRes.set_allocated_executiontime (executionTime);
227
+ if (gtestResultsJson[" failures" ] != 0 ) {
228
+ testRes.set_status (testsgen::TEST_FAILED);
229
+ } else {
230
+ testRes.set_status (testsgen::TEST_PASSED);
227
231
}
228
- testRes. set_status (testsgen::TEST_DEATH );
232
+ fs::remove ( Paths::getGTestResultsJsonPath (projectContext) );
229
233
return testRes;
230
234
}
231
235
0 commit comments