Commit 18dc7a5d authored by Christian Stenger's avatar Christian Stenger
Browse files

AutoTest: Move framework settings into framework manager



Change-Id: I9914291adb102de5136802eb3b6d12afb6276538
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent a6032652
......@@ -64,8 +64,7 @@ public:
ProjectExplorer::StandardRunnable r;
QTC_ASSERT(m_testConfig, return r);
r.executable = m_testConfig->targetFile();
r.commandLineArguments = m_testConfig->argumentsForTestRunner(
*AutotestPlugin::instance()->settings()).join(' ');
r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' ');
r.workingDirectory = m_testConfig->workingDirectory();
r.environment = m_testConfig->environment();
r.runMode = ProjectExplorer::ApplicationLauncher::Gui;
......
......@@ -138,7 +138,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
continue;
}
testProcess.setArguments(testConfiguration->argumentsForTestRunner(settings));
testProcess.setArguments(testConfiguration->argumentsForTestRunner());
testProcess.setWorkingDirectory(testConfiguration->workingDirectory());
if (Utils::HostOsInfo::isWindowsHost())
environment.insert("QT_LOGGING_TO_CONSOLE", "1");
......@@ -304,8 +304,7 @@ void TestRunner::debugTests()
Debugger::DebuggerStartParameters sp;
sp.inferior.executable = commandFilePath;
sp.inferior.commandLineArguments = config->argumentsForTestRunner(
*AutotestPlugin::instance()->settings()).join(' ');
sp.inferior.commandLineArguments = config->argumentsForTestRunner().join(' ');
sp.inferior.environment = config->environment();
sp.inferior.workingDirectory = config->workingDirectory();
sp.displayName = config->displayName();
......
......@@ -24,6 +24,8 @@
****************************************************************************/
#include "testsettings.h"
#include "autotestconstants.h"
#include "iframeworksettings.h"
#include "testframeworkmanager.h"
#include <coreplugin/id.h>
......@@ -33,7 +35,6 @@
namespace Autotest {
namespace Internal {
static const char group[] = "Autotest";
static const char timeoutKey[] = "Timeout";
static const char omitInternalKey[] = "OmitInternal";
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
......@@ -50,7 +51,7 @@ TestSettings::TestSettings()
void TestSettings::toSettings(QSettings *s) const
{
s->beginGroup(group);
s->beginGroup(Constants::SETTINGSGROUP);
s->setValue(timeoutKey, timeout);
s->setValue(omitInternalKey, omitInternalMssg);
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
......@@ -60,20 +61,19 @@ void TestSettings::toSettings(QSettings *s) const
// store frameworks and their current active state
for (const Core::Id &id : frameworks.keys())
s->setValue(QLatin1String(id.name()), frameworks.value(id));
s->beginGroup(qtTestSettings.name());
qtTestSettings.toSettings(s);
s->endGroup();
s->beginGroup(gTestSettings.name());
gTestSettings.toSettings(s);
s->endGroup();
s->endGroup();
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds();
for (const Core::Id &id : registered) {
QSharedPointer<IFrameworkSettings> fSettings = frameworkManager->settingsForTestFramework(id);
if (!fSettings.isNull())
fSettings->toSettings(s);
}
}
void TestSettings::fromSettings(QSettings *s)
{
s->beginGroup(group);
s->beginGroup(Constants::SETTINGSGROUP);
timeout = s->value(timeoutKey, defaultTimeout).toInt();
omitInternalMssg = s->value(omitInternalKey, true).toBool();
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
......@@ -88,15 +88,12 @@ void TestSettings::fromSettings(QSettings *s)
frameworks.insert(id, s->value(QLatin1String(id.name()),
frameworkManager->isActive(id)).toBool());
}
s->beginGroup(qtTestSettings.name());
qtTestSettings.fromSettings(s);
s->endGroup();
s->beginGroup(gTestSettings.name());
gTestSettings.fromSettings(s);
s->endGroup();
s->endGroup();
for (const Core::Id &id : registered) {
QSharedPointer<IFrameworkSettings> fSettings = frameworkManager->settingsForTestFramework(id);
if (!fSettings.isNull())
fSettings->fromSettings(s);
}
}
} // namespace Internal
......
......@@ -25,9 +25,6 @@
#pragma once
#include "gtest/gtestsettings.h"
#include "qtest/qttestsettings.h"
#include <QHash>
namespace Core { class Id; }
......@@ -52,9 +49,6 @@ struct TestSettings
bool autoScroll = true;
bool alwaysParse = true;
QHash<Core::Id, bool> frameworks;
QtTestSettings qtTestSettings;
GTestSettings gTestSettings;
};
} // namespace Internal
......
......@@ -29,6 +29,11 @@
#include "testsettings.h"
#include "testtreemodel.h"
#include "gtest/gtestconstants.h"
#include "gtest/gtestsettings.h"
#include "qtest/qttestconstants.h"
#include "qtest/qttestsettings.h"
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
......@@ -37,6 +42,11 @@
namespace Autotest {
namespace Internal {
static const Core::Id qid
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
static const Core::Id gid
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME);
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
: QWidget(parent)
{
......@@ -66,34 +76,43 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
m_ui.alwaysParseCB->setChecked(settings.alwaysParse);
populateFrameworksListWidget(settings.frameworks);
m_ui.disableCrashhandlerCB->setChecked(settings.qtTestSettings.noCrashHandler);
switch (settings.qtTestSettings.metrics) {
case MetricsType::Walltime:
m_ui.walltimeRB->setChecked(true);
break;
case MetricsType::TickCounter:
m_ui.tickcounterRB->setChecked(true);
break;
case MetricsType::EventCounter:
m_ui.eventCounterRB->setChecked(true);
break;
case MetricsType::CallGrind:
m_ui.callgrindRB->setChecked(true);
break;
case MetricsType::Perf:
m_ui.perfRB->setChecked(true);
break;
default:
m_ui.walltimeRB->setChecked(true);
auto qtTestSettings = qSharedPointerCast<QtTestSettings>(
TestFrameworkManager::instance()->settingsForTestFramework(qid));
if (!qtTestSettings.isNull()) {
m_ui.disableCrashhandlerCB->setChecked(qtTestSettings->noCrashHandler);
switch (qtTestSettings->metrics) {
case MetricsType::Walltime:
m_ui.walltimeRB->setChecked(true);
break;
case MetricsType::TickCounter:
m_ui.tickcounterRB->setChecked(true);
break;
case MetricsType::EventCounter:
m_ui.eventCounterRB->setChecked(true);
break;
case MetricsType::CallGrind:
m_ui.callgrindRB->setChecked(true);
break;
case MetricsType::Perf:
m_ui.perfRB->setChecked(true);
break;
default:
m_ui.walltimeRB->setChecked(true);
}
}
m_ui.runDisabledGTestsCB->setChecked(settings.gTestSettings.runDisabled);
m_ui.repeatGTestsCB->setChecked(settings.gTestSettings.repeat);
m_ui.shuffleGTestsCB->setChecked(settings.gTestSettings.shuffle);
m_ui.repetitionSpin->setValue(settings.gTestSettings.iterations);
m_ui.seedSpin->setValue(settings.gTestSettings.seed);
m_ui.breakOnFailureCB->setChecked(settings.gTestSettings.breakOnFailure);
m_ui.throwOnFailureCB->setChecked(settings.gTestSettings.throwOnFailure);
auto gTestSettings = qSharedPointerCast<GTestSettings>(
TestFrameworkManager::instance()->settingsForTestFramework(gid));
if (!gTestSettings.isNull()) {
m_ui.runDisabledGTestsCB->setChecked(gTestSettings->runDisabled);
m_ui.repeatGTestsCB->setChecked(gTestSettings->repeat);
m_ui.shuffleGTestsCB->setChecked(gTestSettings->shuffle);
m_ui.repetitionSpin->setValue(gTestSettings->iterations);
m_ui.seedSpin->setValue(gTestSettings->seed);
m_ui.breakOnFailureCB->setChecked(gTestSettings->breakOnFailure);
m_ui.throwOnFailureCB->setChecked(gTestSettings->throwOnFailure);
}
}
TestSettings TestSettingsWidget::settings() const
......@@ -108,26 +127,34 @@ TestSettings TestSettingsWidget::settings() const
result.frameworks = frameworks();
// QtTestSettings
result.qtTestSettings.noCrashHandler = m_ui.disableCrashhandlerCB->isChecked();
if (m_ui.walltimeRB->isChecked())
result.qtTestSettings.metrics = MetricsType::Walltime;
else if (m_ui.tickcounterRB->isChecked())
result.qtTestSettings.metrics = MetricsType::TickCounter;
else if (m_ui.eventCounterRB->isChecked())
result.qtTestSettings.metrics = MetricsType::EventCounter;
else if (m_ui.callgrindRB->isChecked())
result.qtTestSettings.metrics = MetricsType::CallGrind;
else if (m_ui.perfRB->isChecked())
result.qtTestSettings.metrics = MetricsType::Perf;
auto qtTestSettings = qSharedPointerCast<QtTestSettings>(
TestFrameworkManager::instance()->settingsForTestFramework(qid));
if (!qtTestSettings.isNull()) {
qtTestSettings->noCrashHandler = m_ui.disableCrashhandlerCB->isChecked();
if (m_ui.walltimeRB->isChecked())
qtTestSettings->metrics = MetricsType::Walltime;
else if (m_ui.tickcounterRB->isChecked())
qtTestSettings->metrics = MetricsType::TickCounter;
else if (m_ui.eventCounterRB->isChecked())
qtTestSettings->metrics = MetricsType::EventCounter;
else if (m_ui.callgrindRB->isChecked())
qtTestSettings->metrics = MetricsType::CallGrind;
else if (m_ui.perfRB->isChecked())
qtTestSettings->metrics = MetricsType::Perf;
}
// GTestSettings
result.gTestSettings.runDisabled = m_ui.runDisabledGTestsCB->isChecked();
result.gTestSettings.repeat = m_ui.repeatGTestsCB->isChecked();
result.gTestSettings.shuffle = m_ui.shuffleGTestsCB->isChecked();
result.gTestSettings.iterations = m_ui.repetitionSpin->value();
result.gTestSettings.seed = m_ui.seedSpin->value();
result.gTestSettings.breakOnFailure = m_ui.breakOnFailureCB->isChecked();
result.gTestSettings.throwOnFailure = m_ui.throwOnFailureCB->isChecked();
auto gTestSettings = qSharedPointerCast<GTestSettings>(
TestFrameworkManager::instance()->settingsForTestFramework(gid));
if (!gTestSettings.isNull()) {
gTestSettings->runDisabled = m_ui.runDisabledGTestsCB->isChecked();
gTestSettings->repeat = m_ui.repeatGTestsCB->isChecked();
gTestSettings->shuffle = m_ui.shuffleGTestsCB->isChecked();
gTestSettings->iterations = m_ui.repetitionSpin->value();
gTestSettings->seed = m_ui.seedSpin->value();
gTestSettings->breakOnFailure = m_ui.breakOnFailureCB->isChecked();
gTestSettings->throwOnFailure = m_ui.throwOnFailureCB->isChecked();
}
return result;
}
......
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