forked from qt-creator/qt-creator
Try to guess run configuration if none is explicitly set
Additionally provide a setting to not display warnings regarding using a guessed run configuration. Change-Id: Ia7647f55e5085ffc84044281c5107770cd30d504 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -30,7 +30,8 @@ TestConfiguration::TestConfiguration(const QString &testClass, const QStringList
|
|||||||
m_testCases(testCases),
|
m_testCases(testCases),
|
||||||
m_testCaseCount(testCaseCount),
|
m_testCaseCount(testCaseCount),
|
||||||
m_unnamedOnly(false),
|
m_unnamedOnly(false),
|
||||||
m_project(0)
|
m_project(0),
|
||||||
|
m_guessedConfiguration(false)
|
||||||
{
|
{
|
||||||
if (testCases.size() != 0) {
|
if (testCases.size() != 0) {
|
||||||
m_testCaseCount = testCases.size();
|
m_testCaseCount = testCases.size();
|
||||||
@@ -102,5 +103,10 @@ void TestConfiguration::setUnnamedOnly(bool unnamedOnly)
|
|||||||
m_unnamedOnly = unnamedOnly;
|
m_unnamedOnly = unnamedOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestConfiguration::setGuessedConfiguration(bool guessed)
|
||||||
|
{
|
||||||
|
m_guessedConfiguration = guessed;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
void setEnvironment(const Utils::Environment &env);
|
void setEnvironment(const Utils::Environment &env);
|
||||||
void setProject(ProjectExplorer::Project *project);
|
void setProject(ProjectExplorer::Project *project);
|
||||||
void setUnnamedOnly(bool unnamedOnly);
|
void setUnnamedOnly(bool unnamedOnly);
|
||||||
|
void setGuessedConfiguration(bool guessed);
|
||||||
|
|
||||||
QString testClass() const { return m_testClass; }
|
QString testClass() const { return m_testClass; }
|
||||||
QStringList testCases() const { return m_testCases; }
|
QStringList testCases() const { return m_testCases; }
|
||||||
@@ -62,7 +63,7 @@ public:
|
|||||||
Utils::Environment environment() const { return m_environment; }
|
Utils::Environment environment() const { return m_environment; }
|
||||||
ProjectExplorer::Project *project() const { return m_project; }
|
ProjectExplorer::Project *project() const { return m_project; }
|
||||||
bool unnamedOnly() const { return m_unnamedOnly; }
|
bool unnamedOnly() const { return m_unnamedOnly; }
|
||||||
|
bool guessedConfiguration() const { return m_guessedConfiguration; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
@@ -80,6 +81,7 @@ private:
|
|||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
Utils::Environment m_environment;
|
Utils::Environment m_environment;
|
||||||
ProjectExplorer::Project *m_project;
|
ProjectExplorer::Project *m_project;
|
||||||
|
bool m_guessedConfiguration;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -185,12 +185,17 @@ void performTestRun(QFutureInterface<void> &futureInterface,
|
|||||||
|
|
||||||
void TestRunner::runTests()
|
void TestRunner::runTests()
|
||||||
{
|
{
|
||||||
|
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
|
||||||
|
const int timeout = settings->timeout;
|
||||||
|
const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
|
||||||
|
const bool displayRunConfigWarnings = !settings->omitRunConfigWarn;
|
||||||
|
|
||||||
// clear old log and output pane
|
// clear old log and output pane
|
||||||
TestResultsPane::instance()->clearContents();
|
TestResultsPane::instance()->clearContents();
|
||||||
|
|
||||||
// handle faulty test configurations
|
// handle faulty test configurations
|
||||||
QList<TestConfiguration *> toBeRemoved;
|
QList<TestConfiguration *> toBeRemoved;
|
||||||
foreach (TestConfiguration *config, m_selectedTests)
|
foreach (TestConfiguration *config, m_selectedTests) {
|
||||||
if (!config->project()) {
|
if (!config->project()) {
|
||||||
toBeRemoved.append(config);
|
toBeRemoved.append(config);
|
||||||
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
|
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
|
||||||
@@ -198,6 +203,12 @@ void TestRunner::runTests()
|
|||||||
"This might be the case for a faulty environment or similar."
|
"This might be the case for a faulty environment or similar."
|
||||||
).arg(config->displayName())));
|
).arg(config->displayName())));
|
||||||
}
|
}
|
||||||
|
if (displayRunConfigWarnings && 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())));
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (TestConfiguration *config, toBeRemoved) {
|
foreach (TestConfiguration *config, toBeRemoved) {
|
||||||
m_selectedTests.removeOne(config);
|
m_selectedTests.removeOne(config);
|
||||||
delete config;
|
delete config;
|
||||||
@@ -243,10 +254,6 @@ void TestRunner::runTests()
|
|||||||
TestResultsPane::instance(), &TestResultsPane::addTestResult,
|
TestResultsPane::instance(), &TestResultsPane::addTestResult,
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
const QSharedPointer<TestSettings> settings = AutotestPlugin::instance()->settings();
|
|
||||||
const int timeout = settings->timeout;
|
|
||||||
const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
|
|
||||||
|
|
||||||
emit testRunStarted();
|
emit testRunStarted();
|
||||||
|
|
||||||
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, timeout, metricsOption, this);
|
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, timeout, metricsOption, this);
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ static const char group[] = "Autotest";
|
|||||||
static const char timeoutKey[] = "Timeout";
|
static const char timeoutKey[] = "Timeout";
|
||||||
static const char metricsKey[] = "Metrics";
|
static const char metricsKey[] = "Metrics";
|
||||||
static const char omitInternalKey[] = "OmitInternal";
|
static const char omitInternalKey[] = "OmitInternal";
|
||||||
|
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
|
||||||
static const int defaultTimeout = 60000;
|
static const int defaultTimeout = 60000;
|
||||||
|
|
||||||
TestSettings::TestSettings()
|
TestSettings::TestSettings()
|
||||||
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true)
|
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ void TestSettings::toSettings(QSettings *s) const
|
|||||||
s->setValue(QLatin1String(timeoutKey), timeout);
|
s->setValue(QLatin1String(timeoutKey), timeout);
|
||||||
s->setValue(QLatin1String(metricsKey), metrics);
|
s->setValue(QLatin1String(metricsKey), metrics);
|
||||||
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
||||||
|
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +69,14 @@ void TestSettings::fromSettings(const QSettings *s)
|
|||||||
timeout = s->value(root + QLatin1String(timeoutKey), defaultTimeout).toInt();
|
timeout = s->value(root + QLatin1String(timeoutKey), defaultTimeout).toInt();
|
||||||
metrics = intToMetrics(s->value(root + QLatin1String(metricsKey), Walltime).toInt());
|
metrics = intToMetrics(s->value(root + QLatin1String(metricsKey), Walltime).toInt());
|
||||||
omitInternalMssg = s->value(root + QLatin1String(omitInternalKey), true).toBool();
|
omitInternalMssg = s->value(root + QLatin1String(omitInternalKey), true).toBool();
|
||||||
|
omitRunConfigWarn = s->value(root + QLatin1String(omitRunConfigWarnKey), false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestSettings::equals(const TestSettings &rhs) const
|
bool TestSettings::equals(const TestSettings &rhs) const
|
||||||
{
|
{
|
||||||
return timeout == rhs.timeout && metrics == rhs.metrics
|
return timeout == rhs.timeout && metrics == rhs.metrics
|
||||||
&& omitInternalMssg == rhs.omitInternalMssg;
|
&& omitInternalMssg == rhs.omitInternalMssg
|
||||||
|
&& omitRunConfigWarn == rhs.omitRunConfigWarn;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TestSettings::metricsTypeToOption(const MetricsType type)
|
QString TestSettings::metricsTypeToOption(const MetricsType type)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ struct TestSettings
|
|||||||
int timeout;
|
int timeout;
|
||||||
MetricsType metrics;
|
MetricsType metrics;
|
||||||
bool omitInternalMssg;
|
bool omitInternalMssg;
|
||||||
|
bool omitRunConfigWarn;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const TestSettings &s1, const TestSettings &s2) { return s1.equals(s2); }
|
inline bool operator==(const TestSettings &s1, const TestSettings &s2) { return s1.equals(s2); }
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
|||||||
{
|
{
|
||||||
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
|
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
|
||||||
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
||||||
|
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
|
||||||
|
|
||||||
switch (settings.metrics) {
|
switch (settings.metrics) {
|
||||||
case MetricsType::Walltime:
|
case MetricsType::Walltime:
|
||||||
@@ -66,6 +67,7 @@ TestSettings TestSettingsWidget::settings() const
|
|||||||
TestSettings result;
|
TestSettings result;
|
||||||
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
|
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
|
||||||
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
||||||
|
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
|
||||||
|
|
||||||
if (m_ui.walltimeRB->isChecked())
|
if (m_ui.walltimeRB->isChecked())
|
||||||
result.metrics = MetricsType::Walltime;
|
result.metrics = MetricsType::Walltime;
|
||||||
|
|||||||
@@ -6,14 +6,23 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>462</width>
|
<width>463</width>
|
||||||
<height>292</height>
|
<height>338</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<widget class="QWidget" name="">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>9</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>435</width>
|
||||||
|
<height>307</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@@ -69,6 +78,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="omitInternalMsgCB">
|
<widget class="QCheckBox" name="omitInternalMsgCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -82,6 +93,18 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="omitRunConfigWarnCB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If checked Warnings regarding a guessed Run Configuration won't be shown.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Omit Run Configuration Warnings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -253,6 +276,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <projectexplorer/environmentaspect.h>
|
#include <projectexplorer/environmentaspect.h>
|
||||||
#include <projectexplorer/localapplicationrunconfiguration.h>
|
#include <projectexplorer/localapplicationrunconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -385,8 +386,10 @@ static void addProjectInformation(TestConfiguration *config, const QString &file
|
|||||||
QString workDir;
|
QString workDir;
|
||||||
QString proFile;
|
QString proFile;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
|
ProjectExplorer::Project *targetProject = 0;
|
||||||
Utils::Environment env;
|
Utils::Environment env;
|
||||||
bool hasDesktopTarget = false;
|
bool hasDesktopTarget = false;
|
||||||
|
bool guessedRunConfiguration = false;
|
||||||
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
|
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
|
||||||
QList<CppTools::ProjectPart::Ptr> projParts = cppMM->projectInfo(project).projectParts();
|
QList<CppTools::ProjectPart::Ptr> projParts = cppMM->projectInfo(project).projectParts();
|
||||||
|
|
||||||
@@ -396,6 +399,7 @@ static void addProjectInformation(TestConfiguration *config, const QString &file
|
|||||||
if (currentFile.path == filePath) {
|
if (currentFile.path == filePath) {
|
||||||
proFile = part->projectFile;
|
proFile = part->projectFile;
|
||||||
displayName = part->displayName;
|
displayName = part->displayName;
|
||||||
|
targetProject = part->project;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,6 +433,34 @@ static void addProjectInformation(TestConfiguration *config, const QString &file
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we could not figure out the run configuration
|
||||||
|
// try to use the run configuration of the parent project
|
||||||
|
if (!hasDesktopTarget && targetProject && !targetFile.isEmpty()) {
|
||||||
|
QList<ProjectExplorer::RunConfiguration *> rcs = target->runConfigurations();
|
||||||
|
foreach (ProjectExplorer::RunConfiguration *rc, rcs) {
|
||||||
|
ProjectExplorer::LocalApplicationRunConfiguration *localRunConfiguration
|
||||||
|
= qobject_cast<ProjectExplorer::LocalApplicationRunConfiguration *>(rc);
|
||||||
|
if (localRunConfiguration) {
|
||||||
|
if (ProjectExplorer::ProjectNode *localRootProjectNode = targetProject->rootProjectNode()) {
|
||||||
|
QList<ProjectExplorer::FileNode *> localFileNodes = localRootProjectNode->fileNodes();
|
||||||
|
if (localFileNodes.size()) {
|
||||||
|
if (localFileNodes.at(0)->path()
|
||||||
|
== targetProject->projectFilePath()) {
|
||||||
|
hasDesktopTarget = true;
|
||||||
|
workDir = Utils::FileUtils::normalizePathName(
|
||||||
|
localRunConfiguration->workingDirectory());
|
||||||
|
ProjectExplorer::EnvironmentAspect *environmentAspect
|
||||||
|
= localRunConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
|
||||||
|
env = environmentAspect->environment();
|
||||||
|
guessedRunConfiguration = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,6 +472,7 @@ static void addProjectInformation(TestConfiguration *config, const QString &file
|
|||||||
config->setEnvironment(env);
|
config->setEnvironment(env);
|
||||||
config->setProject(project);
|
config->setProject(project);
|
||||||
config->setDisplayName(displayName);
|
config->setDisplayName(displayName);
|
||||||
|
config->setGuessedConfiguration(guessedRunConfiguration);
|
||||||
} else {
|
} else {
|
||||||
config->setProFile(proFile);
|
config->setProFile(proFile);
|
||||||
config->setDisplayName(displayName);
|
config->setDisplayName(displayName);
|
||||||
|
|||||||
Reference in New Issue
Block a user