forked from qt-creator/qt-creator
AutoTest: Move framework settings into framework manager
Change-Id: I9914291adb102de5136802eb3b6d12afb6276538 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -80,6 +80,7 @@ HEADERS += \
|
||||
gtest/gtestvisitors.h \
|
||||
gtest/gtestframework.h \
|
||||
gtest/gtestsettings.h \
|
||||
gtest/gtestconstants.h \
|
||||
qtest/qttesttreeitem.h \
|
||||
qtest/qttest_utils.h \
|
||||
qtest/qttestresult.h \
|
||||
@@ -89,6 +90,7 @@ HEADERS += \
|
||||
qtest/qttestparser.h \
|
||||
qtest/qttestframework.h \
|
||||
qtest/qttestsettings.h \
|
||||
qtest/qttestconstants.h \
|
||||
quick/quicktestconfiguration.h \
|
||||
quick/quicktestparser.h \
|
||||
quick/quicktesttreeitem.h \
|
||||
|
@@ -41,5 +41,7 @@ const char TASK_PARSE[] = "AutoTest.Task.Parse";
|
||||
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
|
||||
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
||||
|
||||
|
||||
const char SETTINGSGROUP[] = "Autotest";
|
||||
} // namespace Constants
|
||||
} // namespace Autotest
|
||||
|
@@ -135,7 +135,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
|
||||
m_frameworkManager->registerTestFramework(new QuickTestFramework);
|
||||
m_frameworkManager->registerTestFramework(new GTestFramework);
|
||||
|
||||
m_settings->fromSettings(ICore::settings());
|
||||
m_frameworkManager->synchronizeSettings(ICore::settings());
|
||||
addAutoReleasedObject(new TestSettingsPage(m_settings));
|
||||
addAutoReleasedObject(new TestNavigationWidgetFactory);
|
||||
addAutoReleasedObject(TestResultsPane::instance());
|
||||
|
@@ -24,8 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "gtestconfiguration.h"
|
||||
#include "gtestconstants.h"
|
||||
#include "gtestoutputreader.h"
|
||||
#include "../testsettings.h"
|
||||
#include "gtestsettings.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
@@ -36,25 +38,32 @@ TestOutputReader *GTestConfiguration::outputReader(const QFutureInterface<TestRe
|
||||
return new GTestOutputReader(fi, app, buildDirectory());
|
||||
}
|
||||
|
||||
QStringList GTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
|
||||
QStringList GTestConfiguration::argumentsForTestRunner() const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
const QStringList &testSets = testCases();
|
||||
if (testSets.size())
|
||||
arguments << "--gtest_filter=" + testSets.join(':');
|
||||
if (settings.gTestSettings.runDisabled)
|
||||
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto gSettings = qSharedPointerCast<GTestSettings>(manager->settingsForTestFramework(id));
|
||||
if (gSettings.isNull())
|
||||
return arguments;
|
||||
|
||||
if (gSettings->runDisabled)
|
||||
arguments << "--gtest_also_run_disabled_tests";
|
||||
if (settings.gTestSettings.repeat)
|
||||
arguments << QString("--gtest_repeat=%1").arg(settings.gTestSettings.iterations);
|
||||
if (settings.gTestSettings.shuffle) {
|
||||
arguments << "--gtest_shuffle"
|
||||
<< QString("--gtest_random_seed=%1").arg(settings.gTestSettings.seed);
|
||||
}
|
||||
if (settings.gTestSettings.throwOnFailure)
|
||||
if (gSettings->repeat)
|
||||
arguments << QString("--gtest_repeat=%1").arg(gSettings->iterations);
|
||||
if (gSettings->shuffle)
|
||||
arguments << "--gtest_shuffle" << QString("--gtest_random_seed=%1").arg(gSettings->seed);
|
||||
if (gSettings->throwOnFailure)
|
||||
arguments << "--gtest_throw_on_failure";
|
||||
|
||||
if (runMode() == DebuggableTestConfiguration::Debug) {
|
||||
if (settings.gTestSettings.breakOnFailure)
|
||||
if (gSettings->breakOnFailure)
|
||||
arguments << "--gtest_break_on_failure";
|
||||
}
|
||||
return arguments;
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
explicit GTestConfiguration() {}
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(const TestSettings &settings) const override;
|
||||
QStringList argumentsForTestRunner() const override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
40
src/plugins/autotest/gtest/gtestconstants.h
Normal file
40
src/plugins/autotest/gtest/gtestconstants.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace Autotest {
|
||||
namespace GTest {
|
||||
namespace Constants {
|
||||
|
||||
const char FRAMEWORK_NAME[] = "GTest";
|
||||
const char FRAMEWORK_SETTINGS_CATEGORY[] = QT_TRANSLATE_NOOP("GTestFramework", "Google Test");
|
||||
const unsigned FRAMEWORK_PRIORITY = 10;
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace GTest
|
||||
} // namespace AutoTest
|
@@ -24,6 +24,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "gtestframework.h"
|
||||
#include "gtestconstants.h"
|
||||
#include "gtestsettings.h"
|
||||
#include "gtesttreeitem.h"
|
||||
#include "gtestparser.h"
|
||||
|
||||
@@ -37,18 +39,30 @@ ITestParser *GTestFramework::createTestParser() const
|
||||
|
||||
TestTreeItem *GTestFramework::createRootNode() const
|
||||
{
|
||||
return new GTestTreeItem(QCoreApplication::translate("GTestFramework", "Google Tests"),
|
||||
QString(), TestTreeItem::Root);
|
||||
return new GTestTreeItem(
|
||||
QCoreApplication::translate("GTestFramework",
|
||||
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
{
|
||||
return "GTest";
|
||||
return GTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
unsigned GTestFramework::priority() const
|
||||
{
|
||||
return 10;
|
||||
return GTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
IFrameworkSettings *GTestFramework::createFrameworkSettings() const
|
||||
{
|
||||
return new GTestSettings;
|
||||
}
|
||||
|
||||
bool GTestFramework::hasFrameworkSettings() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,6 +36,8 @@ public:
|
||||
GTestFramework() : ITestFramework(true) {}
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
IFrameworkSettings *createFrameworkSettings() const override;
|
||||
bool hasFrameworkSettings() const override;
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() const override;
|
||||
|
@@ -31,6 +31,8 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class IFrameworkSettings;
|
||||
|
||||
class ITestFramework
|
||||
{
|
||||
public:
|
||||
@@ -43,6 +45,8 @@ public:
|
||||
|
||||
virtual const char *name() const = 0;
|
||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||
virtual bool hasFrameworkSettings() const { return false; }
|
||||
virtual IFrameworkSettings *createFrameworkSettings() const { return 0; }
|
||||
|
||||
TestTreeItem *rootNode()
|
||||
{ if (!m_rootNode)
|
||||
|
@@ -24,8 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qttestconfiguration.h"
|
||||
#include "qttestconstants.h"
|
||||
#include "qttestoutputreader.h"
|
||||
#include "../testsettings.h"
|
||||
#include "qttestsettings.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
@@ -36,19 +38,26 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestR
|
||||
return new QtTestOutputReader(fi, app, buildDirectory());
|
||||
}
|
||||
|
||||
QStringList QtTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
|
||||
QStringList QtTestConfiguration::argumentsForTestRunner() const
|
||||
{
|
||||
QStringList arguments("-xml");
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
const QString &metricsOption
|
||||
= QtTestSettings::metricsTypeToOption(settings.qtTestSettings.metrics);
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
QStringList arguments("-xml");
|
||||
if (testCases().count())
|
||||
arguments << testCases();
|
||||
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = qSharedPointerCast<QtTestSettings>(manager->settingsForTestFramework(id));
|
||||
if (qtSettings.isNull())
|
||||
return arguments;
|
||||
|
||||
const QString &metricsOption = QtTestSettings::metricsTypeToOption(qtSettings->metrics);
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
|
||||
if (runMode() == DebuggableTestConfiguration::Debug) {
|
||||
if (settings.qtTestSettings.noCrashHandler)
|
||||
if (qtSettings->noCrashHandler)
|
||||
arguments << "-nocrashhandler";
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
explicit QtTestConfiguration() {}
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(const TestSettings &settings) const override;
|
||||
QStringList argumentsForTestRunner() const override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
40
src/plugins/autotest/qtest/qttestconstants.h
Normal file
40
src/plugins/autotest/qtest/qttestconstants.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace Autotest {
|
||||
namespace QtTest {
|
||||
namespace Constants {
|
||||
|
||||
const char FRAMEWORK_NAME[] = "QtTest";
|
||||
const char FRAMEWORK_SETTINGS_CATEGORY[] = QT_TRANSLATE_NOOP("QtTestFramework", "Qt Test");
|
||||
const unsigned FRAMEWORK_PRIORITY = 1;
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QtTest
|
||||
} // namespace Autotest
|
@@ -24,7 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qttestframework.h"
|
||||
#include "qttestconstants.h"
|
||||
#include "qttestparser.h"
|
||||
#include "qttestsettings.h"
|
||||
#include "qttesttreeitem.h"
|
||||
|
||||
namespace Autotest {
|
||||
@@ -37,18 +39,30 @@ ITestParser *QtTestFramework::createTestParser() const
|
||||
|
||||
TestTreeItem *QtTestFramework::createRootNode() const
|
||||
{
|
||||
return new QtTestTreeItem(QCoreApplication::translate("QtTestFramework", "Qt Tests"),
|
||||
QString(), TestTreeItem::Root);
|
||||
return new QtTestTreeItem(
|
||||
QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
}
|
||||
|
||||
IFrameworkSettings *QtTestFramework::createFrameworkSettings() const
|
||||
{
|
||||
return new QtTestSettings;
|
||||
}
|
||||
|
||||
bool QtTestFramework::hasFrameworkSettings() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
{
|
||||
return "QtTest";
|
||||
return QtTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
unsigned QtTestFramework::priority() const
|
||||
{
|
||||
return 1;
|
||||
return QtTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,6 +36,8 @@ public:
|
||||
QtTestFramework() : ITestFramework(true) {}
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
IFrameworkSettings *createFrameworkSettings() const override;
|
||||
bool hasFrameworkSettings() const override;
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() const override;
|
||||
|
@@ -24,8 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "quicktestconfiguration.h"
|
||||
#include "../qtest/qttestconstants.h"
|
||||
#include "../qtest/qttestoutputreader.h"
|
||||
#include "../testsettings.h"
|
||||
#include "../qtest/qttestsettings.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
@@ -36,16 +38,23 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface<Te
|
||||
return new QtTestOutputReader(fi, app, buildDirectory());
|
||||
}
|
||||
|
||||
QStringList QuickTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
|
||||
QStringList QuickTestConfiguration::argumentsForTestRunner() const
|
||||
{
|
||||
QStringList arguments({"-xml"});
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
const QString &metricsOption
|
||||
= QtTestSettings::metricsTypeToOption(settings.qtTestSettings.metrics);
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
QStringList arguments("-xml");
|
||||
if (testCases().count())
|
||||
arguments << testCases();
|
||||
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = qSharedPointerCast<QtTestSettings>(manager->settingsForTestFramework(id));
|
||||
if (qtSettings.isNull())
|
||||
return arguments;
|
||||
|
||||
const QString &metricsOption = QtTestSettings::metricsTypeToOption(qtSettings->metrics);
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
explicit QuickTestConfiguration() {}
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(const TestSettings &settings) const override;
|
||||
QStringList argumentsForTestRunner() const override;
|
||||
|
||||
void setUnnamedOnly(bool unnamedOnly);
|
||||
bool unnamedOnly() const { return m_unnamedOnly; }
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include "testoutputreader.h"
|
||||
#include "testrunconfiguration.h"
|
||||
#include "testrunner.h"
|
||||
#include "testsettings.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/projectinfo.h>
|
||||
|
@@ -45,7 +45,6 @@ namespace Internal {
|
||||
class TestOutputReader;
|
||||
class TestResult;
|
||||
class TestRunConfiguration;
|
||||
struct TestSettings;
|
||||
|
||||
using TestResultPtr = QSharedPointer<TestResult>;
|
||||
|
||||
@@ -86,7 +85,7 @@ public:
|
||||
|
||||
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const = 0;
|
||||
virtual QStringList argumentsForTestRunner(const TestSettings &settings) const = 0;
|
||||
virtual QStringList argumentsForTestRunner() const = 0;
|
||||
|
||||
private:
|
||||
QStringList m_testCases;
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "testframeworkmanager.h"
|
||||
#include "autotestconstants.h"
|
||||
#include "autotestplugin.h"
|
||||
#include "iframeworksettings.h"
|
||||
#include "itestframework.h"
|
||||
#include "itestparser.h"
|
||||
#include "testrunner.h"
|
||||
@@ -74,6 +76,11 @@ bool TestFrameworkManager::registerTestFramework(ITestFramework *framework)
|
||||
// TODO check for unique priority before registering
|
||||
qCDebug(LOG) << "Registering" << id;
|
||||
m_registeredFrameworks.insert(id, framework);
|
||||
|
||||
if (framework->hasFrameworkSettings()) {
|
||||
QSharedPointer<IFrameworkSettings> frameworkSettings(framework->createFrameworkSettings());
|
||||
m_frameworkSettings.insert(id, frameworkSettings);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -145,6 +152,23 @@ ITestParser *TestFrameworkManager::testParserForTestFramework(const Core::Id &fr
|
||||
return testParser;
|
||||
}
|
||||
|
||||
QSharedPointer<IFrameworkSettings> TestFrameworkManager::settingsForTestFramework(
|
||||
const Core::Id &frameworkId) const
|
||||
{
|
||||
return m_frameworkSettings.contains(frameworkId) ? m_frameworkSettings.value(frameworkId)
|
||||
: QSharedPointer<IFrameworkSettings>();
|
||||
}
|
||||
|
||||
void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
||||
{
|
||||
AutotestPlugin::instance()->settings()->fromSettings(s);
|
||||
for (const Core::Id &id : m_frameworkSettings.keys()) {
|
||||
QSharedPointer<IFrameworkSettings> fSettings = settingsForTestFramework(id);
|
||||
if (!fSettings.isNull())
|
||||
fSettings->fromSettings(s);
|
||||
}
|
||||
}
|
||||
|
||||
bool TestFrameworkManager::isActive(const Core::Id &frameworkId) const
|
||||
{
|
||||
ITestFramework *framework = m_registeredFrameworks.value(frameworkId);
|
||||
|
@@ -28,11 +28,16 @@
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class Id; }
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class IFrameworkSettings;
|
||||
class ITestFramework;
|
||||
class ITestParser;
|
||||
class TestRunner;
|
||||
@@ -55,6 +60,8 @@ public:
|
||||
|
||||
TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const;
|
||||
ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const;
|
||||
QSharedPointer<IFrameworkSettings> settingsForTestFramework(const Core::Id &frameworkId) const;
|
||||
void synchronizeSettings(QSettings *s);
|
||||
bool isActive(const Core::Id &frameworkId) const;
|
||||
bool hasActiveFrameworks() const;
|
||||
|
||||
@@ -62,6 +69,7 @@ private:
|
||||
QVector<Core::Id> activeFrameworkIds() const;
|
||||
explicit TestFrameworkManager();
|
||||
QHash<Core::Id, ITestFramework *> m_registeredFrameworks;
|
||||
QHash<Core::Id, QSharedPointer<IFrameworkSettings> > m_frameworkSettings;
|
||||
TestTreeModel *m_testTreeModel;
|
||||
TestRunner *m_testRunner;
|
||||
|
||||
|
@@ -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> ®istered = 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user