forked from qt-creator/qt-creator
AutoTest: Tweak run after successful build
Make it possible to distinguish between all and selected test cases also for the automatic run after build feature. Change-Id: I91715a7ae4f09cea2e31844940a6b21ae9e62157 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
#include "testprojectsettings.h"
|
#include "testprojectsettings.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
@@ -61,12 +60,19 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
|||||||
m_activeFrameworks->setRootIsDecorated(false);
|
m_activeFrameworks->setRootIsDecorated(false);
|
||||||
groupBoxLayout->addWidget(new QLabel(tr("Active frameworks:")));
|
groupBoxLayout->addWidget(new QLabel(tr("Active frameworks:")));
|
||||||
groupBoxLayout->addWidget(m_activeFrameworks);
|
groupBoxLayout->addWidget(m_activeFrameworks);
|
||||||
m_runAfterBuild = new QCheckBox(tr("Automatically run after build"));
|
auto horizontalLayout = new QHBoxLayout;
|
||||||
m_runAfterBuild->setChecked(m_projectSettings->runAfterBuild());
|
horizontalLayout->addWidget(new QLabel(tr("Automatically run tests after build")));
|
||||||
groupBoxLayout->addWidget(m_runAfterBuild);
|
m_runAfterBuild = new QComboBox;
|
||||||
|
m_runAfterBuild->addItem(tr("None"));
|
||||||
|
m_runAfterBuild->addItem(tr("All"));
|
||||||
|
m_runAfterBuild->addItem(tr("Selected"));
|
||||||
|
m_runAfterBuild->setCurrentIndex(int(m_projectSettings->runAfterBuild()));
|
||||||
|
horizontalLayout->addWidget(m_runAfterBuild);
|
||||||
|
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||||
|
groupBoxLayout->addLayout(horizontalLayout);
|
||||||
generalWidget->setLayout(groupBoxLayout);
|
generalWidget->setLayout(groupBoxLayout);
|
||||||
|
|
||||||
auto horizontalLayout = new QHBoxLayout;
|
horizontalLayout = new QHBoxLayout;
|
||||||
horizontalLayout->addWidget(m_useGlobalSettings);
|
horizontalLayout->addWidget(m_useGlobalSettings);
|
||||||
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||||
verticalLayout->addLayout(horizontalLayout);
|
verticalLayout->addLayout(horizontalLayout);
|
||||||
@@ -90,8 +96,10 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
|
|||||||
});
|
});
|
||||||
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
|
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
|
||||||
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
|
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
|
||||||
connect(m_runAfterBuild, &QCheckBox::toggled,
|
connect(m_runAfterBuild, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
m_projectSettings, &TestProjectSettings::setRunAfterBuild);
|
this, [this](int index) {
|
||||||
|
m_projectSettings->setRunAfterBuild(RunAfterBuildMode(index));
|
||||||
|
});
|
||||||
m_syncFrameworksTimer.setSingleShot(true);
|
m_syncFrameworksTimer.setSingleShot(true);
|
||||||
connect(&m_syncFrameworksTimer, &QTimer::timeout,
|
connect(&m_syncFrameworksTimer, &QTimer::timeout,
|
||||||
TestTreeModel::instance(), &TestTreeModel::synchronizeTestFrameworks);
|
TestTreeModel::instance(), &TestTreeModel::synchronizeTestFrameworks);
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
@@ -55,7 +54,7 @@ private:
|
|||||||
TestProjectSettings *m_projectSettings;
|
TestProjectSettings *m_projectSettings;
|
||||||
QComboBox *m_useGlobalSettings = nullptr;
|
QComboBox *m_useGlobalSettings = nullptr;
|
||||||
QTreeWidget *m_activeFrameworks = nullptr;
|
QTreeWidget *m_activeFrameworks = nullptr;
|
||||||
QCheckBox *m_runAfterBuild = nullptr;
|
QComboBox *m_runAfterBuild = nullptr;
|
||||||
QTimer m_syncFrameworksTimer;
|
QTimer m_syncFrameworksTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -88,7 +88,8 @@ void TestProjectSettings::load()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QVariant runAfterBuild = m_project->namedSettings(SK_RUN_AFTER_BUILD);
|
const QVariant runAfterBuild = m_project->namedSettings(SK_RUN_AFTER_BUILD);
|
||||||
m_runAfterBuild = runAfterBuild.isValid() ? runAfterBuild.toBool() : false;
|
m_runAfterBuild = runAfterBuild.isValid() ? RunAfterBuildMode(runAfterBuild.toInt())
|
||||||
|
: RunAfterBuildMode::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestProjectSettings::save()
|
void TestProjectSettings::save()
|
||||||
@@ -99,7 +100,7 @@ void TestProjectSettings::save()
|
|||||||
for (auto it = m_activeTestFrameworks.cbegin(); it != end; ++it)
|
for (auto it = m_activeTestFrameworks.cbegin(); it != end; ++it)
|
||||||
activeFrameworks.insert(it.key().toString(), it.value());
|
activeFrameworks.insert(it.key().toString(), it.value());
|
||||||
m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks);
|
m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks);
|
||||||
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, m_runAfterBuild);
|
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, int(m_runAfterBuild));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "testsettings.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
@@ -39,8 +41,8 @@ public:
|
|||||||
|
|
||||||
void setUseGlobalSettings(bool useGlobal);
|
void setUseGlobalSettings(bool useGlobal);
|
||||||
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
||||||
void setRunAfterBuild(bool enabled) {m_runAfterBuild = enabled; }
|
void setRunAfterBuild(RunAfterBuildMode mode) {m_runAfterBuild = mode; }
|
||||||
bool runAfterBuild() const { return m_runAfterBuild; }
|
RunAfterBuildMode runAfterBuild() const { return m_runAfterBuild; }
|
||||||
void setActiveFrameworks(const QMap<Core::Id, bool> enabledFrameworks)
|
void setActiveFrameworks(const QMap<Core::Id, bool> enabledFrameworks)
|
||||||
{ m_activeTestFrameworks = enabledFrameworks; }
|
{ m_activeTestFrameworks = enabledFrameworks; }
|
||||||
QMap<Core::Id, bool> activeFrameworks() const { return m_activeTestFrameworks; }
|
QMap<Core::Id, bool> activeFrameworks() const { return m_activeTestFrameworks; }
|
||||||
@@ -51,7 +53,7 @@ private:
|
|||||||
|
|
||||||
ProjectExplorer::Project *m_project;
|
ProjectExplorer::Project *m_project;
|
||||||
bool m_useGlobalSettings = true;
|
bool m_useGlobalSettings = true;
|
||||||
bool m_runAfterBuild = false;
|
RunAfterBuildMode m_runAfterBuild = RunAfterBuildMode::None;
|
||||||
QMap<Core::Id, bool> m_activeTestFrameworks;
|
QMap<Core::Id, bool> m_activeTestFrameworks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -674,11 +674,11 @@ void TestRunner::buildFinished(bool success)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool runAfterBuild()
|
static RunAfterBuildMode runAfterBuild()
|
||||||
{
|
{
|
||||||
Project *project = SessionManager::startupProject();
|
Project *project = SessionManager::startupProject();
|
||||||
if (!project)
|
if (!project)
|
||||||
return false;
|
return RunAfterBuildMode::None;
|
||||||
|
|
||||||
if (!project->namedSettings(Constants::SK_USE_GLOBAL).isValid())
|
if (!project->namedSettings(Constants::SK_USE_GLOBAL).isValid())
|
||||||
return AutotestPlugin::settings()->runAfterBuild;
|
return AutotestPlugin::settings()->runAfterBuild;
|
||||||
@@ -696,14 +696,16 @@ void TestRunner::onBuildQueueFinished(bool success)
|
|||||||
if (!success || m_runMode != TestRunMode::None)
|
if (!success || m_runMode != TestRunMode::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!runAfterBuild())
|
RunAfterBuildMode mode = runAfterBuild();
|
||||||
|
if (mode == RunAfterBuildMode::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto testTreeModel = TestTreeModel::instance();
|
auto testTreeModel = TestTreeModel::instance();
|
||||||
if (!testTreeModel->hasTests())
|
if (!testTreeModel->hasTests())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setSelectedTests(testTreeModel->getAllTestCases());
|
setSelectedTests(mode == RunAfterBuildMode::All ? testTreeModel->getAllTestCases()
|
||||||
|
: testTreeModel->getSelectedTests());
|
||||||
prepareToRunTests(TestRunMode::RunAfterBuild);
|
prepareToRunTests(TestRunMode::RunAfterBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ void TestSettings::toSettings(QSettings *s) const
|
|||||||
s->setValue(popupOnStartKey, popupOnStart);
|
s->setValue(popupOnStartKey, popupOnStart);
|
||||||
s->setValue(popupOnFinishKey, popupOnFinish);
|
s->setValue(popupOnFinishKey, popupOnFinish);
|
||||||
s->setValue(popupOnFailKey, popupOnFail);
|
s->setValue(popupOnFailKey, popupOnFail);
|
||||||
s->setValue(runAfterBuildKey, runAfterBuild);
|
s->setValue(runAfterBuildKey, int(runAfterBuild));
|
||||||
// store frameworks and their current active and grouping state
|
// store frameworks and their current active and grouping state
|
||||||
for (const Core::Id &id : frameworks.keys()) {
|
for (const Core::Id &id : frameworks.keys()) {
|
||||||
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
||||||
@@ -89,7 +89,8 @@ void TestSettings::fromSettings(QSettings *s)
|
|||||||
popupOnStart = s->value(popupOnStartKey, true).toBool();
|
popupOnStart = s->value(popupOnStartKey, true).toBool();
|
||||||
popupOnFinish = s->value(popupOnFinishKey, true).toBool();
|
popupOnFinish = s->value(popupOnFinishKey, true).toBool();
|
||||||
popupOnFail = s->value(popupOnFailKey, false).toBool();
|
popupOnFail = s->value(popupOnFailKey, false).toBool();
|
||||||
runAfterBuild = s->value(runAfterBuildKey, false).toBool();
|
runAfterBuild = RunAfterBuildMode(s->value(runAfterBuildKey,
|
||||||
|
int(RunAfterBuildMode::None)).toInt());
|
||||||
// try to get settings for registered frameworks
|
// try to get settings for registered frameworks
|
||||||
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
||||||
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
||||||
|
@@ -36,6 +36,13 @@ QT_END_NAMESPACE
|
|||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
enum class RunAfterBuildMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
All,
|
||||||
|
Selected
|
||||||
|
};
|
||||||
|
|
||||||
struct TestSettings
|
struct TestSettings
|
||||||
{
|
{
|
||||||
TestSettings();
|
TestSettings();
|
||||||
@@ -52,7 +59,7 @@ struct TestSettings
|
|||||||
bool popupOnStart = true;
|
bool popupOnStart = true;
|
||||||
bool popupOnFinish = true;
|
bool popupOnFinish = true;
|
||||||
bool popupOnFail = false;
|
bool popupOnFail = false;
|
||||||
bool runAfterBuild = false;
|
RunAfterBuildMode runAfterBuild = RunAfterBuildMode::None;
|
||||||
QHash<Core::Id, bool> frameworks;
|
QHash<Core::Id, bool> frameworks;
|
||||||
QHash<Core::Id, bool> frameworksGrouping;
|
QHash<Core::Id, bool> frameworksGrouping;
|
||||||
};
|
};
|
||||||
|
@@ -69,7 +69,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
|||||||
m_ui.openResultsOnStartCB->setChecked(settings.popupOnStart);
|
m_ui.openResultsOnStartCB->setChecked(settings.popupOnStart);
|
||||||
m_ui.openResultsOnFinishCB->setChecked(settings.popupOnFinish);
|
m_ui.openResultsOnFinishCB->setChecked(settings.popupOnFinish);
|
||||||
m_ui.openResultsOnFailCB->setChecked(settings.popupOnFail);
|
m_ui.openResultsOnFailCB->setChecked(settings.popupOnFail);
|
||||||
m_ui.runAfterBuildCB->setChecked(settings.runAfterBuild);
|
m_ui.runAfterBuildCB->setCurrentIndex(int(settings.runAfterBuild));
|
||||||
populateFrameworksListWidget(settings.frameworks);
|
populateFrameworksListWidget(settings.frameworks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ TestSettings TestSettingsWidget::settings() const
|
|||||||
result.popupOnStart = m_ui.openResultsOnStartCB->isChecked();
|
result.popupOnStart = m_ui.openResultsOnStartCB->isChecked();
|
||||||
result.popupOnFinish = m_ui.openResultsOnFinishCB->isChecked();
|
result.popupOnFinish = m_ui.openResultsOnFinishCB->isChecked();
|
||||||
result.popupOnFail = m_ui.openResultsOnFailCB->isChecked();
|
result.popupOnFail = m_ui.openResultsOnFailCB->isChecked();
|
||||||
result.runAfterBuild = m_ui.runAfterBuildCB->isChecked();
|
result.runAfterBuild = RunAfterBuildMode(m_ui.runAfterBuildCB->currentIndex());
|
||||||
frameworkSettings(result);
|
frameworkSettings(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -145,14 +145,50 @@ Warning: this is an experimental feature and might lead to failing to execute th
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="runAfterBuildCB">
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
<property name="toolTip">
|
<item>
|
||||||
<string>Runs all tests automatically if a build succeeded.</string>
|
<widget class="QLabel" name="label_2">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="text">
|
<string>Automatically run</string>
|
||||||
<string>Automatically run after build</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="runAfterBuildCB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Runs chosen tests automatically if a build succeeded.</string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>None</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>All</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Selected</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
|
||||||
|
Reference in New Issue
Block a user