forked from qt-creator/qt-creator
TestOutputReader: Don't store test process
Test process may be deleted when reader is still alive. Change-Id: I534d5bcebc6040305c4d937174db9444f6633df8 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -31,8 +31,12 @@ BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult>
|
|||||||
, m_logLevel(log)
|
, m_logLevel(log)
|
||||||
, m_reportLevel(report)
|
, m_reportLevel(report)
|
||||||
{
|
{
|
||||||
if (m_testApplication)
|
if (!testApplication)
|
||||||
connect(m_testApplication, &QtcProcess::done, this, &BoostTestOutputReader::onDone);
|
return;
|
||||||
|
|
||||||
|
connect(testApplication, &QtcProcess::done, this, [this, testApplication] {
|
||||||
|
onDone(testApplication->exitCode());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// content of "error:..." / "info:..." / ... messages
|
// content of "error:..." / "info:..." / ... messages
|
||||||
@@ -378,10 +382,10 @@ TestResult BoostTestOutputReader::createDefaultResult() const
|
|||||||
return BoostTestResult(id(), m_currentModule, m_projectFile, m_currentTest, m_currentSuite);
|
return BoostTestResult(id(), m_currentModule, m_projectFile, m_currentTest, m_currentSuite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoostTestOutputReader::onDone() {
|
void BoostTestOutputReader::onDone(int exitCode)
|
||||||
int exitCode = m_testApplication->exitCode();
|
{
|
||||||
if (m_reportLevel == ReportLevel::No && m_testCaseCount != -1) {
|
if (m_reportLevel == ReportLevel::No && m_testCaseCount != -1) {
|
||||||
int reportedFailsAndSkips = m_summary[ResultType::Fail] + m_summary[ResultType::Skip];
|
const int reportedFailsAndSkips = m_summary[ResultType::Fail] + m_summary[ResultType::Skip];
|
||||||
m_summary.insert(ResultType::Pass, m_testCaseCount - reportedFailsAndSkips);
|
m_summary.insert(ResultType::Pass, m_testCaseCount - reportedFailsAndSkips);
|
||||||
}
|
}
|
||||||
// boost::exit_success (0), boost::exit_test_failure (201)
|
// boost::exit_success (0), boost::exit_test_failure (201)
|
||||||
|
@@ -24,7 +24,7 @@ protected:
|
|||||||
TestResult createDefaultResult() const override;
|
TestResult createDefaultResult() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onDone();
|
void onDone(int exitCode);
|
||||||
void sendCompleteInformation();
|
void sendCompleteInformation();
|
||||||
void handleMessageMatch(const QRegularExpressionMatch &match);
|
void handleMessageMatch(const QRegularExpressionMatch &match);
|
||||||
void reportNoOutputFinish(const QString &description, ResultType type);
|
void reportNoOutputFinish(const QString &description, ResultType type);
|
||||||
|
@@ -24,9 +24,9 @@ GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureI
|
|||||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||||
, m_projectFile(projectFile)
|
, m_projectFile(projectFile)
|
||||||
{
|
{
|
||||||
if (m_testApplication) {
|
if (testApplication) {
|
||||||
connect(m_testApplication, &QtcProcess::done, this, [this] {
|
connect(testApplication, &QtcProcess::done, this, [this, testApplication] {
|
||||||
const int exitCode = m_testApplication->exitCode();
|
const int exitCode = testApplication->exitCode();
|
||||||
if (exitCode == 1 && !m_description.isEmpty()) {
|
if (exitCode == 1 && !m_description.isEmpty()) {
|
||||||
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
|
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
|
||||||
.arg(m_description).arg(id()), ResultType::MessageFatal);
|
.arg(m_description).arg(id()), ResultType::MessageFatal);
|
||||||
|
@@ -29,7 +29,6 @@ FilePath TestOutputReader::constructSourceFilePath(const FilePath &path, const Q
|
|||||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
QtcProcess *testApplication, const FilePath &buildDirectory)
|
QtcProcess *testApplication, const FilePath &buildDirectory)
|
||||||
: m_futureInterface(futureInterface)
|
: m_futureInterface(futureInterface)
|
||||||
, m_testApplication(testApplication)
|
|
||||||
, m_buildDir(buildDirectory)
|
, m_buildDir(buildDirectory)
|
||||||
, m_id(testApplication ? testApplication->commandLine().executable().toUserOutput() : QString())
|
, m_id(testApplication ? testApplication->commandLine().executable().toUserOutput() : QString())
|
||||||
{
|
{
|
||||||
@@ -41,11 +40,11 @@ TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInt
|
|||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (m_testApplication) {
|
if (testApplication) {
|
||||||
m_testApplication->setStdOutLineCallback([this, &chopLineBreak](const QString &line) {
|
testApplication->setStdOutLineCallback([this, &chopLineBreak](const QString &line) {
|
||||||
processStdOutput(chopLineBreak(line.toUtf8()));
|
processStdOutput(chopLineBreak(line.toUtf8()));
|
||||||
});
|
});
|
||||||
m_testApplication->setStdErrLineCallback([this, &chopLineBreak](const QString &line) {
|
testApplication->setStdErrLineCallback([this, &chopLineBreak](const QString &line) {
|
||||||
processStdError(chopLineBreak(line.toUtf8()));
|
processStdError(chopLineBreak(line.toUtf8()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,6 @@ protected:
|
|||||||
|
|
||||||
void reportResult(const TestResult &result);
|
void reportResult(const TestResult &result);
|
||||||
QFutureInterface<TestResult> m_futureInterface;
|
QFutureInterface<TestResult> m_futureInterface;
|
||||||
Utils::QtcProcess *m_testApplication; // not owned
|
|
||||||
Utils::FilePath m_buildDir;
|
Utils::FilePath m_buildDir;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QHash<ResultType, int> m_summary;
|
QHash<ResultType, int> m_summary;
|
||||||
|
Reference in New Issue
Block a user