AutoTest: Fix special handling for gtest exit

Similar to what has been done for boost test - there is special
handling when the test applications process exits.
This was no more executed since moving over to use the task tree.

Change-Id: I982b7e4dfe6de4bbbe75c8d3ec0f62d0c3037f4a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Stenger
2023-06-20 13:54:30 +02:00
parent e0bdec5fcf
commit 17c8a6bfe2
2 changed files with 12 additions and 12 deletions

View File

@@ -23,18 +23,6 @@ GTestOutputReader::GTestOutputReader(Process *testApplication,
: TestOutputReader(testApplication, buildDirectory) : TestOutputReader(testApplication, buildDirectory)
, m_projectFile(projectFile) , m_projectFile(projectFile)
{ {
if (testApplication) {
connect(testApplication, &Process::done, this, [this, testApplication] {
const int exitCode = testApplication->exitCode();
if (exitCode == 1 && !m_description.isEmpty()) {
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
.arg(m_description).arg(id()), ResultType::MessageFatal);
}
// on Windows abort() will result in normal termination, but exit code will be set to 3
if (HostOsInfo::isWindowsHost() && exitCode == 3)
reportCrash();
});
}
} }
void GTestOutputReader::processOutputLine(const QByteArray &outputLine) void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
@@ -182,6 +170,17 @@ TestResult GTestOutputReader::createDefaultResult() const
return result; return result;
} }
void GTestOutputReader::onDone(int exitCode)
{
if (exitCode == 1 && !m_description.isEmpty()) {
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
.arg(m_description).arg(id()), ResultType::MessageFatal);
}
// on Windows abort() will result in normal termination, but exit code will be set to 3
if (HostOsInfo::isWindowsHost() && exitCode == 3)
reportCrash();
}
void GTestOutputReader::setCurrentTestCase(const QString &testCase) void GTestOutputReader::setCurrentTestCase(const QString &testCase)
{ {
m_currentTestCase = testCase; m_currentTestCase = testCase;

View File

@@ -19,6 +19,7 @@ protected:
TestResult createDefaultResult() const override; TestResult createDefaultResult() const override;
private: private:
void onDone(int exitCode) override;
void setCurrentTestCase(const QString &testCase); void setCurrentTestCase(const QString &testCase);
void setCurrentTestSuite(const QString &testSuite); void setCurrentTestSuite(const QString &testSuite);
void handleDescriptionAndReportResult(const TestResult &testResult); void handleDescriptionAndReportResult(const TestResult &testResult);