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_reportLevel(report)
|
||||
{
|
||||
if (m_testApplication)
|
||||
connect(m_testApplication, &QtcProcess::done, this, &BoostTestOutputReader::onDone);
|
||||
if (!testApplication)
|
||||
return;
|
||||
|
||||
connect(testApplication, &QtcProcess::done, this, [this, testApplication] {
|
||||
onDone(testApplication->exitCode());
|
||||
});
|
||||
}
|
||||
|
||||
// content of "error:..." / "info:..." / ... messages
|
||||
@@ -378,10 +382,10 @@ TestResult BoostTestOutputReader::createDefaultResult() const
|
||||
return BoostTestResult(id(), m_currentModule, m_projectFile, m_currentTest, m_currentSuite);
|
||||
}
|
||||
|
||||
void BoostTestOutputReader::onDone() {
|
||||
int exitCode = m_testApplication->exitCode();
|
||||
void BoostTestOutputReader::onDone(int exitCode)
|
||||
{
|
||||
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);
|
||||
}
|
||||
// boost::exit_success (0), boost::exit_test_failure (201)
|
||||
|
@@ -24,7 +24,7 @@ protected:
|
||||
TestResult createDefaultResult() const override;
|
||||
|
||||
private:
|
||||
void onDone();
|
||||
void onDone(int exitCode);
|
||||
void sendCompleteInformation();
|
||||
void handleMessageMatch(const QRegularExpressionMatch &match);
|
||||
void reportNoOutputFinish(const QString &description, ResultType type);
|
||||
|
@@ -24,9 +24,9 @@ GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureI
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
, m_projectFile(projectFile)
|
||||
{
|
||||
if (m_testApplication) {
|
||||
connect(m_testApplication, &QtcProcess::done, this, [this] {
|
||||
const int exitCode = m_testApplication->exitCode();
|
||||
if (testApplication) {
|
||||
connect(testApplication, &QtcProcess::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);
|
||||
|
@@ -29,7 +29,6 @@ FilePath TestOutputReader::constructSourceFilePath(const FilePath &path, const Q
|
||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
QtcProcess *testApplication, const FilePath &buildDirectory)
|
||||
: m_futureInterface(futureInterface)
|
||||
, m_testApplication(testApplication)
|
||||
, m_buildDir(buildDirectory)
|
||||
, m_id(testApplication ? testApplication->commandLine().executable().toUserOutput() : QString())
|
||||
{
|
||||
@@ -41,11 +40,11 @@ TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInt
|
||||
return line;
|
||||
};
|
||||
|
||||
if (m_testApplication) {
|
||||
m_testApplication->setStdOutLineCallback([this, &chopLineBreak](const QString &line) {
|
||||
if (testApplication) {
|
||||
testApplication->setStdOutLineCallback([this, &chopLineBreak](const QString &line) {
|
||||
processStdOutput(chopLineBreak(line.toUtf8()));
|
||||
});
|
||||
m_testApplication->setStdErrLineCallback([this, &chopLineBreak](const QString &line) {
|
||||
testApplication->setStdErrLineCallback([this, &chopLineBreak](const QString &line) {
|
||||
processStdError(chopLineBreak(line.toUtf8()));
|
||||
});
|
||||
}
|
||||
|
@@ -47,7 +47,6 @@ protected:
|
||||
|
||||
void reportResult(const TestResult &result);
|
||||
QFutureInterface<TestResult> m_futureInterface;
|
||||
Utils::QtcProcess *m_testApplication; // not owned
|
||||
Utils::FilePath m_buildDir;
|
||||
QString m_id;
|
||||
QHash<ResultType, int> m_summary;
|
||||
|
Reference in New Issue
Block a user