Commit d0b258a5 authored by Christian Stenger's avatar Christian Stenger Committed by Eike Ziller
Browse files

Make TestRunner more thread-safe



Change-Id: I42e5c9e26a45ef2875cf70e1c5e3b989bcce4de8
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent eca35ce8
......@@ -22,15 +22,13 @@
#include "autotestconstants.h"
#include <projectexplorer/project.h>
#include <utils/environment.h>
#include <QObject>
#include <QPointer>
#include <QStringList>
namespace ProjectExplorer {
class Project;
}
namespace Autotest {
namespace Internal {
......@@ -68,7 +66,7 @@ public:
QString workingDirectory() const { return m_workingDir; }
QString displayName() const { return m_displayName; }
Utils::Environment environment() const { return m_environment; }
ProjectExplorer::Project *project() const { return m_project; }
ProjectExplorer::Project *project() const { return m_project.data(); }
bool unnamedOnly() const { return m_unnamedOnly; }
bool guessedConfiguration() const { return m_guessedConfiguration; }
TestType testType() const { return m_type; }
......@@ -85,7 +83,7 @@ private:
QString m_workingDir;
QString m_displayName;
Utils::Environment m_environment;
ProjectExplorer::Project *m_project;
QPointer<ProjectExplorer::Project> m_project;
bool m_guessedConfiguration;
TestType m_type;
};
......
......@@ -44,7 +44,7 @@ namespace Internal {
static TestRunner *m_instance = 0;
void emitTestResultCreated(TestResult *testResult)
static void emitTestResultCreated(TestResult *testResult)
{
emit m_instance->testResultCreated(testResult);
}
......@@ -105,9 +105,9 @@ void TestRunner::setSelectedTests(const QList<TestConfiguration *> &selected)
m_selectedTests = selected;
}
void performTestRun(QFutureInterface<void> &futureInterface,
const QList<TestConfiguration *> selectedTests, const int timeout,
const QString metricsOption, TestRunner* testRunner)
static void performTestRun(QFutureInterface<void> &futureInterface,
const QList<TestConfiguration *> selectedTests, const int timeout,
const QString metricsOption)
{
int testCaseCount = 0;
foreach (TestConfiguration *config, selectedTests) {
......@@ -124,9 +124,6 @@ void performTestRun(QFutureInterface<void> &futureInterface,
QProcess testProcess;
testProcess.setReadChannelMode(QProcess::MergedChannels);
testProcess.setReadChannel(QProcess::StandardOutput);
QObject::connect(testRunner, &TestRunner::requestStopTestRun, &testProcess, [&] () {
futureInterface.cancel(); // this kills the process if that is still in the running loop
});
TestOutputReader outputReader(&testProcess);
QObject::connect(&outputReader, &TestOutputReader::increaseProgress, [&] () {
......@@ -278,11 +275,15 @@ void TestRunner::runTests()
Qt::QueuedConnection);
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, settings->timeout,
metricsOption, this);
metricsOption);
Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
Autotest::Constants::TASK_INDEX);
connect(progress, &Core::FutureProgress::finished,
TestRunner::instance(), &TestRunner::onFinished);
connect(this, &TestRunner::requestStopTestRun, progress, [progress]() {
progress->future().cancel();
});
}
void TestRunner::buildProject(ProjectExplorer::Project *project)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment