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
...@@ -80,6 +80,7 @@ HEADERS += \ ...@@ -80,6 +80,7 @@ HEADERS += \
gtest/gtestvisitors.h \ gtest/gtestvisitors.h \
gtest/gtestframework.h \ gtest/gtestframework.h \
gtest/gtestsettings.h \ gtest/gtestsettings.h \
gtest/gtestconstants.h \
qtest/qttesttreeitem.h \ qtest/qttesttreeitem.h \
qtest/qttest_utils.h \ qtest/qttest_utils.h \
qtest/qttestresult.h \ qtest/qttestresult.h \
...@@ -89,6 +90,7 @@ HEADERS += \ ...@@ -89,6 +90,7 @@ HEADERS += \
qtest/qttestparser.h \ qtest/qttestparser.h \
qtest/qttestframework.h \ qtest/qttestframework.h \
qtest/qttestsettings.h \ qtest/qttestsettings.h \
qtest/qttestconstants.h \
quick/quicktestconfiguration.h \ quick/quicktestconfiguration.h \
quick/quicktestparser.h \ quick/quicktestparser.h \
quick/quicktesttreeitem.h \ quick/quicktesttreeitem.h \
......
...@@ -41,5 +41,7 @@ const char TASK_PARSE[] = "AutoTest.Task.Parse"; ...@@ -41,5 +41,7 @@ const char TASK_PARSE[] = "AutoTest.Task.Parse";
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
const char SETTINGSGROUP[] = "Autotest";
} // namespace Constants } // namespace Constants
} // namespace Autotest } // namespace Autotest
...@@ -135,7 +135,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri ...@@ -135,7 +135,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
m_frameworkManager->registerTestFramework(new QuickTestFramework); m_frameworkManager->registerTestFramework(new QuickTestFramework);
m_frameworkManager->registerTestFramework(new GTestFramework); m_frameworkManager->registerTestFramework(new GTestFramework);
m_settings->fromSettings(ICore::settings()); m_frameworkManager->synchronizeSettings(ICore::settings());
addAutoReleasedObject(new TestSettingsPage(m_settings)); addAutoReleasedObject(new TestSettingsPage(m_settings));
addAutoReleasedObject(new TestNavigationWidgetFactory); addAutoReleasedObject(new TestNavigationWidgetFactory);
addAutoReleasedObject(TestResultsPane::instance()); addAutoReleasedObject(TestResultsPane::instance());
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
****************************************************************************/ ****************************************************************************/
#include "gtestconfiguration.h" #include "gtestconfiguration.h"
#include "gtestconstants.h"
#include "gtestoutputreader.h" #include "gtestoutputreader.h"
#include "../testsettings.h" #include "gtestsettings.h"
#include "../testframeworkmanager.h"
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
...@@ -36,25 +38,32 @@ TestOutputReader *GTestConfiguration::outputReader(const QFutureInterface<TestRe ...@@ -36,25 +38,32 @@ TestOutputReader *GTestConfiguration::outputReader(const QFutureInterface<TestRe
return new GTestOutputReader(fi, app, buildDirectory()); 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; QStringList arguments;
const QStringList &testSets = testCases(); const QStringList &testSets = testCases();
if (testSets.size()) if (testSets.size())
arguments << "--gtest_filter=" + testSets.join(':'); 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"; arguments << "--gtest_also_run_disabled_tests";
if (settings.gTestSettings.repeat) if (gSettings->repeat)
arguments << QString("--gtest_repeat=%1").arg(settings.gTestSettings.iterations); arguments << QString("--gtest_repeat=%1").arg(gSettings->iterations);
if (settings.gTestSettings.shuffle) { if (gSettings->shuffle)
arguments << "--gtest_shuffle" arguments << "--gtest_shuffle" << QString("--gtest_random_seed=%1").arg(gSettings->seed);
<< QString("--gtest_random_seed=%1").arg(settings.gTestSettings.seed); if (gSettings->throwOnFailure)
}
if (settings.gTestSettings.throwOnFailure)
arguments << "--gtest_throw_on_failure"; arguments << "--gtest_throw_on_failure";
if (runMode() == DebuggableTestConfiguration::Debug) { if (runMode() == DebuggableTestConfiguration::Debug) {
if (settings.gTestSettings.breakOnFailure) if (gSettings->breakOnFailure)
arguments << "--gtest_break_on_failure"; arguments << "--gtest_break_on_failure";
} }
return arguments; return arguments;
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
explicit GTestConfiguration() {} explicit GTestConfiguration() {}
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const override; QProcess *app) const override;
QStringList argumentsForTestRunner(const TestSettings &settings) const override; QStringList argumentsForTestRunner() const override;
}; };
} // namespace Internal } // namespace Internal
......
/****************************************************************************
**
** 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 @@ ...@@ -24,6 +24,8 @@
****************************************************************************/ ****************************************************************************/
#include "gtestframework.h" #include "gtestframework.h"
#include "gtestconstants.h"
#include "gtestsettings.h"
#include "gtesttreeitem.h" #include "gtesttreeitem.h"
#include "gtestparser.h" #include "gtestparser.h"
...@@ -37,18 +39,30 @@ ITestParser *GTestFramework::createTestParser() const ...@@ -37,18 +39,30 @@ ITestParser *GTestFramework::createTestParser() const
TestTreeItem *GTestFramework::createRootNode() const TestTreeItem *GTestFramework::createRootNode() const
{ {
return new GTestTreeItem(QCoreApplication::translate("GTestFramework", "Google Tests"), return new GTestTreeItem(
QString(), TestTreeItem::Root); QCoreApplication::translate("GTestFramework",
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
QString(), TestTreeItem::Root);
} }
const char *GTestFramework::name() const const char *GTestFramework::name() const
{ {
return "GTest"; return GTest::Constants::FRAMEWORK_NAME;
} }
unsigned GTestFramework::priority() const 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 } // namespace Internal
......
...@@ -36,6 +36,8 @@ public: ...@@ -36,6 +36,8 @@ public:
GTestFramework() : ITestFramework(true) {} GTestFramework() : ITestFramework(true) {}
const char *name() const override; const char *name() const override;
unsigned priority() const override; unsigned priority() const override;
IFrameworkSettings *createFrameworkSettings() const override;
bool hasFrameworkSettings() const override;
protected: protected:
ITestParser *createTestParser() const override; ITestParser *createTestParser() const override;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
class IFrameworkSettings;
class ITestFramework class ITestFramework
{ {
public: public:
...@@ -43,6 +45,8 @@ public: ...@@ -43,6 +45,8 @@ public:
virtual const char *name() const = 0; virtual const char *name() const = 0;
virtual unsigned priority() const = 0; // should this be modifyable? virtual unsigned priority() const = 0; // should this be modifyable?
virtual bool hasFrameworkSettings() const { return false; }
virtual IFrameworkSettings *createFrameworkSettings() const { return 0; }
TestTreeItem *rootNode() TestTreeItem *rootNode()
{ if (!m_rootNode) { if (!m_rootNode)
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
****************************************************************************/ ****************************************************************************/
#include "qttestconfiguration.h" #include "qttestconfiguration.h"
#include "qttestconstants.h"
#include "qttestoutputreader.h" #include "qttestoutputreader.h"
#include "../testsettings.h" #include "qttestsettings.h"
#include "../testframeworkmanager.h"
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
...@@ -36,19 +38,26 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestR ...@@ -36,19 +38,26 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestR
return new QtTestOutputReader(fi, app, buildDirectory()); return new QtTestOutputReader(fi, app, buildDirectory());
} }
QStringList QtTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const QStringList QtTestConfiguration::argumentsForTestRunner() const
{ {
static const Core::Id id
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
QStringList arguments("-xml"); QStringList arguments("-xml");
if (testCases().count())
arguments << testCases();
const QString &metricsOption TestFrameworkManager *manager = TestFrameworkManager::instance();
= QtTestSettings::metricsTypeToOption(settings.qtTestSettings.metrics); auto qtSettings = qSharedPointerCast<QtTestSettings>(manager->settingsForTestFramework(id));
if (qtSettings.isNull())
return arguments;
const QString &metricsOption = QtTestSettings::metricsTypeToOption(qtSettings->metrics);
if (!metricsOption.isEmpty()) if (!metricsOption.isEmpty())
arguments << metricsOption; arguments << metricsOption;
if (testCases().count())
arguments << testCases();
if (runMode() == DebuggableTestConfiguration::Debug) { if (runMode() == DebuggableTestConfiguration::Debug) {
if (settings.qtTestSettings.noCrashHandler) if (qtSettings->noCrashHandler)
arguments << "-nocrashhandler"; arguments << "-nocrashhandler";
} }
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
explicit QtTestConfiguration() {} explicit QtTestConfiguration() {}
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const override; QProcess *app) const override;
QStringList argumentsForTestRunner(const TestSettings &settings) const override; QStringList argumentsForTestRunner() const override;
}; };
} // namespace Internal } // namespace Internal
......
/****************************************************************************
**
** 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 @@ ...@@ -24,7 +24,9 @@
****************************************************************************/ ****************************************************************************/
#include "qttestframework.h" #include "qttestframework.h"
#include "qttestconstants.h"
#include "qttestparser.h" #include "qttestparser.h"
#include "qttestsettings.h"
#include "qttesttreeitem.h" #include "qttesttreeitem.h"
namespace Autotest { namespace Autotest {
...@@ -37,18 +39,30 @@ ITestParser *QtTestFramework::createTestParser() const ...@@ -37,18 +39,30 @@ ITestParser *QtTestFramework::createTestParser() const
TestTreeItem *QtTestFramework::createRootNode() const TestTreeItem *QtTestFramework::createRootNode() const
{ {
return new QtTestTreeItem(QCoreApplication::translate("QtTestFramework", "Qt Tests"), return new QtTestTreeItem(
QString(), TestTreeItem::Root); 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 const char *QtTestFramework::name() const
{ {
return "QtTest"; return QtTest::Constants::FRAMEWORK_NAME;
} }
unsigned QtTestFramework::priority() const unsigned QtTestFramework::priority() const
{ {
return 1; return QtTest::Constants::FRAMEWORK_PRIORITY;
} }
} // namespace Internal } // namespace Internal
......
...@@ -36,6 +36,8 @@ public: ...@@ -36,6 +36,8 @@ public:
QtTestFramework() : ITestFramework(true) {} QtTestFramework() : ITestFramework(true) {}
const char *name() const override; const char *name() const override;
unsigned priority() const override; unsigned priority() const override;
IFrameworkSettings *createFrameworkSettings() const override;
bool hasFrameworkSettings() const override;
protected: protected:
ITestParser *createTestParser() const override; ITestParser *createTestParser() const override;
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
****************************************************************************/ ****************************************************************************/
#include "quicktestconfiguration.h" #include "quicktestconfiguration.h"
#include "../qtest/qttestconstants.h"
#include "../qtest/qttestoutputreader.h" #include "../qtest/qttestoutputreader.h"
#include "../testsettings.h" #include "../qtest/qttestsettings.h"
#include "../testframeworkmanager.h"
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
...@@ -36,16 +38,23 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface<Te ...@@ -36,16 +38,23 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface<Te
return new QtTestOutputReader(fi, app, buildDirectory()); 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 QStringList arguments("-xml");
= QtTestSettings::metricsTypeToOption(settings.qtTestSettings.metrics);
if (!metricsOption.isEmpty())
arguments << metricsOption;
if (testCases().count()) if (testCases().count())
arguments << testCases(); 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; return arguments;
} }
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
explicit QuickTestConfiguration() {} explicit QuickTestConfiguration() {}
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const override; QProcess *app) const override;
QStringList argumentsForTestRunner(const TestSettings &settings) const override; QStringList argumentsForTestRunner() const override;
void setUnnamedOnly(bool unnamedOnly); void setUnnamedOnly(bool unnamedOnly);
bool unnamedOnly() const { return m_unnamedOnly; } bool unnamedOnly() const { return m_unnamedOnly; }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "testoutputreader.h" #include "testoutputreader.h"
#include "testrunconfiguration.h" #include "testrunconfiguration.h"
#include "testrunner.h" #include "testrunner.h"
#include "testsettings.h"
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <cpptools/projectinfo.h> #include <cpptools/projectinfo.h>
......
...@@ -45,7 +45,6 @@ namespace Internal { ...@@ -45,7 +45,6 @@ namespace Internal {
class TestOutputReader; class TestOutputReader;
class TestResult; class TestResult;
class TestRunConfiguration; class TestRunConfiguration;
struct TestSettings;
using TestResultPtr = QSharedPointer<TestResult>; using TestResultPtr = QSharedPointer<TestResult>;
...@@ -86,7 +85,7 @@ public: ...@@ -86,7 +85,7 @@ public:
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const = 0; QProcess *app) const = 0;
virtual QStringList argumentsForTestRunner(const TestSettings &settings) const = 0; virtual QStringList argumentsForTestRunner() const = 0;
private: private:
QStringList m_testCases; QStringList m_testCases;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "testframeworkmanager.h" #include "testframeworkmanager.h"
#include "autotestconstants.h" #include "autotestconstants.h"
#include "autotestplugin.h"
#include "iframeworksettings.h"
#include "itestframework.h" #include "itestframework.