Skip to content

Commit fcf19c6

Browse files
committed
fix tests with timeout
1 parent 940d468 commit fcf19c6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

server/src/coverage/TestRunner.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,18 @@ testsgen::TestResultObject TestRunner::runTest(const BuildRunCommand &command, c
195195
auto res = command.runCommand.run(projectContext.buildDir, true, true, testTimeout);
196196
GTestLogger::log(res.output);
197197

198-
nlohmann::json gtestResultsJson = JsonUtils::getJsonFromFile(Paths::getGTestResultsJsonPath(projectContext));
199198
auto executionTime = new google::protobuf::Duration;
200-
if (!google::protobuf::util::TimeUtil::FromString(gtestResultsJson["time"], executionTime)) {
201-
LOG_S(WARNING) << "Cannot parse duration of test execution";
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 {
205+
if (testTimeout.has_value()) {
206+
*executionTime = google::protobuf::util::TimeUtil::SecondsToDuration(testTimeout.value().count());
207+
} else {
208+
LOG_S(WARNING) << "Google test results are not generated, timeout not found";
209+
}
202210
}
203211

204212
testsgen::TestResultObject testRes;

0 commit comments

Comments
 (0)