Commit c0f76a26 authored by Eike Ziller's avatar Eike Ziller
Browse files

Merge remote-tracking branch 'origin/3.5'

Change-Id: I8dffae0c2c62f6a6a3bfa5642c079fc9bad1412d
parents 9e8df7d2 1108556f
......@@ -168,7 +168,7 @@ void AutotestPlugin::onRunAllTriggered()
TestRunner *runner = TestRunner::instance();
TestTreeModel *model = TestTreeModel::instance();
runner->setSelectedTests(model->getAllTestCases());
runner->runTests();
runner->prepareToRunTests();
}
void AutotestPlugin::onRunSelectedTriggered()
......@@ -176,7 +176,7 @@ void AutotestPlugin::onRunSelectedTriggered()
TestRunner *runner = TestRunner::instance();
TestTreeModel *model = TestTreeModel::instance();
runner->setSelectedTests(model->getSelectedTests());
runner->runTests();
runner->prepareToRunTests();
}
void AutotestPlugin::updateMenuItemsEnabledState()
......
......@@ -249,7 +249,7 @@ void TestNavigationWidget::onRunThisTestTriggered()
if (TestConfiguration *configuration = m_model->getTestConfiguration(item)) {
TestRunner *runner = TestRunner::instance();
runner->setSelectedTests( {configuration} );
runner->runTests();
runner->prepareToRunTests();
}
}
}
......
......@@ -288,14 +288,14 @@ void TestResultsPane::onRunAllTriggered()
{
TestRunner *runner = TestRunner::instance();
runner->setSelectedTests(TestTreeModel::instance()->getAllTestCases());
runner->runTests();
runner->prepareToRunTests();
}
void TestResultsPane::onRunSelectedTriggered()
{
TestRunner *runner = TestRunner::instance();
runner->setSelectedTests(TestTreeModel::instance()->getSelectedTests());
runner->runTests();
runner->prepareToRunTests();
}
void TestResultsPane::initializeFilterMenu()
......
......@@ -86,7 +86,6 @@ TestRunner *TestRunner::instance()
TestRunner::TestRunner(QObject *parent) :
QObject(parent),
m_building(false),
m_executingTests(false)
{
}
......@@ -197,12 +196,9 @@ void performTestRun(QFutureInterface<void> &futureInterface,
futureInterface.setProgressValue(testCaseCount);
}
void TestRunner::runTests()
void TestRunner::prepareToRunTests()
{
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
const int timeout = settings->timeout;
const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
const bool displayRunConfigWarnings = !settings->omitRunConfigWarn;
const bool omitRunConfigWarnings = AutotestPlugin::instance()->settings()->omitRunConfigWarn;
m_executingTests = true;
emit testRunStarted();
......@@ -211,7 +207,7 @@ void TestRunner::runTests()
TestResultsPane::instance()->clearContents();
foreach (TestConfiguration *config, m_selectedTests) {
if (displayRunConfigWarnings && config->guessedConfiguration()) {
if (!omitRunConfigWarnings && config->guessedConfiguration()) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
tr("Project's run configuration was guessed for \"%1\".\n"
"This might cause trouble during execution.").arg(config->displayName())));
......@@ -237,38 +233,31 @@ void TestRunner::runTests()
ProjectExplorer::Internal::ProjectExplorerSettings projectExplorerSettings =
ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings();
if (projectExplorerSettings.buildBeforeDeploy) {
if (!project->hasActiveBuildSettings()) {
if (!projectExplorerSettings.buildBeforeDeploy) {
runTests();
} else {
if (project->hasActiveBuildSettings()) {
buildProject(project);
} else {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("Project is not configured. Canceling test run.")));
onFinished();
return;
}
auto connection = connect(this, &TestRunner::requestStopTestRun, [&] () {
ProjectExplorer::BuildManager::instance()->cancel();
m_building = false;
m_buildSucceeded = false;
});
buildProject(project);
while (m_building) {
qApp->processEvents();
}
disconnect(connection);
if (!m_buildSucceeded) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("Build failed. Canceling test run.")));
onFinished();
return;
}
}
}
void TestRunner::runTests()
{
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
const QString &metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
connect(this, &TestRunner::testResultCreated,
TestResultsPane::instance(), &TestResultsPane::addTestResult,
Qt::QueuedConnection);
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, timeout, metricsOption, this);
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, settings->timeout,
metricsOption, this);
Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
Autotest::Constants::TASK_INDEX);
connect(progress, &Core::FutureProgress::finished,
......@@ -277,9 +266,9 @@ void TestRunner::runTests()
void TestRunner::buildProject(ProjectExplorer::Project *project)
{
m_building = true;
m_buildSucceeded = false;
ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
m_buildConnect = connect(this, &TestRunner::requestStopTestRun,
buildManager, &ProjectExplorer::BuildManager::cancel);
connect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
this, &TestRunner::buildFinished);
ProjectExplorer::ProjectExplorerPlugin::buildProject(project);
......@@ -287,11 +276,18 @@ void TestRunner::buildProject(ProjectExplorer::Project *project)
void TestRunner::buildFinished(bool success)
{
disconnect(m_buildConnect);
ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
disconnect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
this, &TestRunner::buildFinished);
m_building = false;
m_buildSucceeded = success;
if (success) {
runTests();
} else {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("Build failed. Canceling test run.")));
onFinished();
}
}
void TestRunner::onFinished()
......
......@@ -51,7 +51,7 @@ signals:
void requestStopTestRun();
public slots:
void runTests();
void prepareToRunTests();
private slots:
void buildProject(ProjectExplorer::Project *project);
......@@ -59,13 +59,14 @@ private slots:
void onFinished();
private:
void runTests();
explicit TestRunner(QObject *parent = 0);
QList<TestConfiguration *> m_selectedTests;
bool m_building;
bool m_buildSucceeded;
bool m_executingTests;
// temporarily used if building before running is necessary
QMetaObject::Connection m_buildConnect;
};
} // namespace Internal
......
isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$(QTC_SOURCE)
isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$(QTC_BUILD)
isEmpty(IDE_SOURCE_TREE): error("Set QTC_SOURCE environment variable")
isEmpty(IDE_BUILD_TREE): error("Set QTC_BUILD environment variable")
TEMPLATE = aux
content.files = \
autotest
STATIC_BASE = $$PWD
STATIC_DIRS = templates
content.path = $$QTC_PREFIX/share/qtcreator/templates/wizards
for(data_dir, STATIC_DIRS) {
files = $$files($$STATIC_BASE/$$data_dir/*, true)
for(file, files): !exists($$file/*): STATIC_FILES += $$file
}
OTHER_FILES += $${content.files}
include($$IDE_SOURCE_TREE/share/qtcreator/static.pri)
INSTALLS += content
Markdown is supported
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