forked from qt-creator/qt-creator
AutoTest: Merge settings and tools hierarchies [1/2]
Currently living in the settings files to keep changes small, will be renamed in a second step. This allows the settings aspects to be used in their short form and overall removes some indirections. Change-Id: I099369b62239aed8192613a04bca958a660c36c7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -13,7 +13,6 @@ add_qtc_plugin(AutoTest
|
||||
boost/boostcodeparser.cpp boost/boostcodeparser.h
|
||||
boost/boosttestconfiguration.cpp boost/boosttestconfiguration.h
|
||||
boost/boosttestconstants.h
|
||||
boost/boosttestframework.cpp boost/boosttestframework.h
|
||||
boost/boosttestoutputreader.cpp boost/boosttestoutputreader.h
|
||||
boost/boosttestparser.cpp boost/boosttestparser.h
|
||||
boost/boosttestresult.cpp boost/boosttestresult.h
|
||||
@@ -21,19 +20,16 @@ add_qtc_plugin(AutoTest
|
||||
boost/boosttesttreeitem.cpp boost/boosttesttreeitem.h
|
||||
catch/catchcodeparser.cpp catch/catchcodeparser.h
|
||||
catch/catchconfiguration.cpp catch/catchconfiguration.h
|
||||
catch/catchframework.h catch/catchframework.cpp catch/catchoutputreader.h
|
||||
catch/catchoutputreader.cpp catch/catchresult.h catch/catchresult.cpp catch/catchtestparser.h
|
||||
catch/catchtestparser.cpp catch/catchtreeitem.h catch/catchtreeitem.cpp
|
||||
catch/catchtestsettings.cpp catch/catchtestsettings.h
|
||||
ctest/ctestconfiguration.cpp ctest/ctestconfiguration.h
|
||||
ctest/ctestoutputreader.cpp ctest/ctestoutputreader.h
|
||||
ctest/ctestsettings.cpp ctest/ctestsettings.h
|
||||
ctest/ctesttool.cpp ctest/ctesttool.h
|
||||
ctest/ctesttreeitem.cpp ctest/ctesttreeitem.h
|
||||
gtest/gtest_utils.cpp gtest/gtest_utils.h
|
||||
gtest/gtestconfiguration.cpp gtest/gtestconfiguration.h
|
||||
gtest/gtestconstants.h
|
||||
gtest/gtestframework.cpp gtest/gtestframework.h
|
||||
gtest/gtestoutputreader.cpp gtest/gtestoutputreader.h
|
||||
gtest/gtestparser.cpp gtest/gtestparser.h
|
||||
gtest/gtestresult.cpp gtest/gtestresult.h
|
||||
@@ -47,7 +43,6 @@ add_qtc_plugin(AutoTest
|
||||
qtest/qttest_utils.cpp qtest/qttest_utils.h
|
||||
qtest/qttestconfiguration.cpp qtest/qttestconfiguration.h
|
||||
qtest/qttestconstants.h
|
||||
qtest/qttestframework.cpp qtest/qttestframework.h
|
||||
qtest/qttestoutputreader.cpp qtest/qttestoutputreader.h
|
||||
qtest/qttestparser.cpp qtest/qttestparser.h
|
||||
qtest/qttestresult.cpp qtest/qttestresult.h
|
||||
|
@@ -18,11 +18,11 @@
|
||||
#include "testtreeitem.h"
|
||||
#include "testtreemodel.h"
|
||||
|
||||
#include "boost/boosttestframework.h"
|
||||
#include "catch/catchframework.h"
|
||||
#include "ctest/ctesttool.h"
|
||||
#include "gtest/gtestframework.h"
|
||||
#include "qtest/qttestframework.h"
|
||||
#include "boost/boosttestsettings.h"
|
||||
#include "catch/catchtestsettings.h"
|
||||
#include "ctest/ctestsettings.h"
|
||||
#include "gtest/gtestsettings.h"
|
||||
#include "qtest/qttestsettings.h"
|
||||
#include "quick/quicktestframework.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -128,13 +128,13 @@ AutotestPluginPrivate::AutotestPluginPrivate()
|
||||
{
|
||||
dd = this; // Needed as the code below access it via the static plugin interface
|
||||
initializeMenuEntries();
|
||||
m_frameworkManager.registerTestFramework(new QtTestFramework);
|
||||
m_frameworkManager.registerTestFramework(new QuickTestFramework);
|
||||
m_frameworkManager.registerTestFramework(new GTestFramework);
|
||||
m_frameworkManager.registerTestFramework(new BoostTestFramework);
|
||||
m_frameworkManager.registerTestFramework(new CatchFramework);
|
||||
m_frameworkManager.registerTestFramework(&theQtTestFramework());
|
||||
m_frameworkManager.registerTestFramework(&theQuickTestFramework());
|
||||
m_frameworkManager.registerTestFramework(&theGTestFramework());
|
||||
m_frameworkManager.registerTestFramework(&theBoostTestFramework());
|
||||
m_frameworkManager.registerTestFramework(&theCatchFramework());
|
||||
|
||||
m_frameworkManager.registerTestTool(new CTestTool);
|
||||
m_frameworkManager.registerTestTool(&theCTestTool());
|
||||
|
||||
m_frameworkManager.synchronizeSettings();
|
||||
m_resultsPane = TestResultsPane::instance();
|
||||
|
@@ -78,8 +78,8 @@ void AutoTestUnitTests::initTestCase()
|
||||
|
||||
// Enable quick check for derived tests
|
||||
static const Id id = Id("AutoTest.Framework.QtTest");
|
||||
static_cast<Autotest::Internal::QtTestSettings *>(
|
||||
TestFrameworkManager::frameworkForId(id)->testSettings())
|
||||
static_cast<Autotest::Internal::QtTestFramework *>(
|
||||
TestFrameworkManager::frameworkForId(id))
|
||||
->quickCheckForDerivedTests.setValue(true);
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,10 @@ namespace Internal {
|
||||
|
||||
TestOutputReader *BoostTestConfiguration::createOutputReader(Process *app) const
|
||||
{
|
||||
auto settings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
||||
BoostTestFramework &settings = *static_cast<BoostTestFramework *>(framework());
|
||||
return new BoostTestOutputReader(app, buildDirectory(), projectFile(),
|
||||
LogLevel(settings->logLevel.value()),
|
||||
ReportLevel(settings->reportLevel.value()));
|
||||
LogLevel(settings.logLevel()),
|
||||
ReportLevel(settings.reportLevel()));
|
||||
}
|
||||
|
||||
enum class InterferingType { Options, EnvironmentVariables };
|
||||
@@ -86,19 +86,19 @@ static QStringList filterInterfering(const QStringList &provided, QStringList *o
|
||||
|
||||
QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
auto boostSettings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
||||
BoostTestFramework &boostSettings = *static_cast<BoostTestFramework *>(framework());
|
||||
QStringList arguments;
|
||||
arguments << "-l" << BoostTestSettings::logLevelToOption(LogLevel(boostSettings->logLevel()));
|
||||
arguments << "-r" << BoostTestSettings::reportLevelToOption(ReportLevel(boostSettings->reportLevel()));
|
||||
arguments << "-l" << BoostTestFramework::logLevelToOption(LogLevel(boostSettings.logLevel()));
|
||||
arguments << "-r" << BoostTestFramework::reportLevelToOption(ReportLevel(boostSettings.reportLevel()));
|
||||
|
||||
if (boostSettings->randomize())
|
||||
arguments << QString("--random=").append(QString::number(boostSettings->seed()));
|
||||
if (boostSettings.randomize())
|
||||
arguments << QString("--random=").append(QString::number(boostSettings.seed()));
|
||||
|
||||
if (boostSettings->systemErrors())
|
||||
if (boostSettings.systemErrors())
|
||||
arguments << "-s";
|
||||
if (boostSettings->fpExceptions())
|
||||
if (boostSettings.fpExceptions())
|
||||
arguments << "--detect_fp_exceptions";
|
||||
if (!boostSettings->memLeaks())
|
||||
if (!boostSettings.memLeaks())
|
||||
arguments << "--detect_memory_leaks=0";
|
||||
|
||||
// TODO improve the test case gathering and arguments building to avoid too long command lines
|
||||
|
@@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "boosttestframework.h"
|
||||
|
||||
#include "boosttestconstants.h"
|
||||
#include "boosttesttreeitem.h"
|
||||
#include "boosttestparser.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
ITestParser *BoostTestFramework::createTestParser()
|
||||
{
|
||||
return new BoostTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *BoostTestFramework::createRootNode()
|
||||
{
|
||||
return new BoostTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *BoostTestFramework::name() const
|
||||
{
|
||||
return BoostTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString BoostTestFramework::displayName() const
|
||||
{
|
||||
return Tr::tr(BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned BoostTestFramework::priority() const
|
||||
{
|
||||
return BoostTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
@@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "boosttestsettings.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class BoostTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
BoostTestFramework() : ITestFramework(true) {}
|
||||
|
||||
private:
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
BoostTestSettings m_settings{settingsId()};
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
@@ -4,10 +4,13 @@
|
||||
#include "boosttestsettings.h"
|
||||
|
||||
#include "boosttestconstants.h"
|
||||
|
||||
#include "boosttesttreeitem.h"
|
||||
#include "boosttestparser.h"
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace Layouting;
|
||||
@@ -15,11 +18,15 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
BoostTestSettings::BoostTestSettings(Id settingsId)
|
||||
BoostTestFramework &theBoostTestFramework()
|
||||
{
|
||||
static BoostTestFramework framework;
|
||||
return framework;
|
||||
}
|
||||
|
||||
BoostTestFramework::BoostTestFramework()
|
||||
: ITestFramework(true)
|
||||
{
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setSettingsGroups("Autotest", "BoostTest");
|
||||
|
||||
setLayouter([this] {
|
||||
@@ -88,7 +95,7 @@ BoostTestSettings::BoostTestSettings(Id settingsId)
|
||||
memLeaks.setToolTip(Tr::tr("Enable memory leak detection."));
|
||||
}
|
||||
|
||||
QString BoostTestSettings::logLevelToOption(const LogLevel logLevel)
|
||||
QString BoostTestFramework::logLevelToOption(const LogLevel logLevel)
|
||||
{
|
||||
switch (logLevel) {
|
||||
case LogLevel::All: return QString("all");
|
||||
@@ -106,7 +113,7 @@ QString BoostTestSettings::logLevelToOption(const LogLevel logLevel)
|
||||
return {};
|
||||
}
|
||||
|
||||
QString BoostTestSettings::reportLevelToOption(const ReportLevel reportLevel)
|
||||
QString BoostTestFramework::reportLevelToOption(const ReportLevel reportLevel)
|
||||
{
|
||||
switch (reportLevel) {
|
||||
case ReportLevel::Confirm: return QString("confirm");
|
||||
@@ -117,4 +124,47 @@ QString BoostTestSettings::reportLevelToOption(const ReportLevel reportLevel)
|
||||
return {};
|
||||
}
|
||||
|
||||
ITestParser *BoostTestFramework::createTestParser()
|
||||
{
|
||||
return new BoostTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *BoostTestFramework::createRootNode()
|
||||
{
|
||||
return new BoostTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *BoostTestFramework::name() const
|
||||
{
|
||||
return BoostTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString BoostTestFramework::displayName() const
|
||||
{
|
||||
return Tr::tr(BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned BoostTestFramework::priority() const
|
||||
{
|
||||
return BoostTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
// BoostSettingsPage
|
||||
|
||||
class BoostSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
BoostSettingsPage()
|
||||
{
|
||||
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix(QString("%1.%2")
|
||||
.arg(BoostTest::Constants::FRAMEWORK_PRIORITY)
|
||||
.arg(BoostTest::Constants::FRAMEWORK_NAME)));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setSettingsProvider([] { return &theBoostTestFramework() ; });
|
||||
}
|
||||
};
|
||||
|
||||
const BoostSettingsPage settingsPage;
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestframework.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
@@ -30,10 +30,16 @@ enum class ReportLevel
|
||||
No
|
||||
};
|
||||
|
||||
class BoostTestSettings : public Core::PagedSettings
|
||||
class BoostTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
explicit BoostTestSettings(Utils::Id settingsId);
|
||||
BoostTestFramework();
|
||||
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
static QString logLevelToOption(const LogLevel logLevel);
|
||||
static QString reportLevelToOption(const ReportLevel reportLevel);
|
||||
@@ -47,6 +53,8 @@ public:
|
||||
Utils::BoolAspect memLeaks{this};
|
||||
};
|
||||
|
||||
BoostTestFramework &theBoostTestFramework();
|
||||
|
||||
} // Autotest::Internal
|
||||
|
||||
Q_DECLARE_METATYPE(Autotest::Internal::LogLevel)
|
||||
|
@@ -84,32 +84,30 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
' ', Qt::SkipEmptyParts), omitted);
|
||||
}
|
||||
|
||||
auto settings = static_cast<CatchTestSettings *>(framework()->testSettings());
|
||||
if (!settings)
|
||||
return arguments;
|
||||
CatchFramework &settings = *static_cast<CatchFramework *>(framework());
|
||||
|
||||
if (settings->abortAfterChecked.value())
|
||||
arguments << "-x" << QString::number(settings->abortAfter.value());
|
||||
if (settings->samplesChecked.value())
|
||||
arguments << "--benchmark-samples" << QString::number(settings->benchmarkSamples.value());
|
||||
if (settings->resamplesChecked.value())
|
||||
arguments << "--benchmark-resamples" << QString::number(settings->benchmarkResamples.value());
|
||||
if (settings->warmupChecked.value())
|
||||
arguments << "--benchmark-warmup-time" << QString::number(settings->benchmarkWarmupTime.value());
|
||||
if (settings->confidenceIntervalChecked.value())
|
||||
arguments << "--benchmark-confidence-interval" << QString::number(settings->confidenceInterval.value());
|
||||
if (settings->noAnalysis.value())
|
||||
if (settings.abortAfterChecked())
|
||||
arguments << "-x" << QString::number(settings.abortAfter());
|
||||
if (settings.samplesChecked())
|
||||
arguments << "--benchmark-samples" << QString::number(settings.benchmarkSamples());
|
||||
if (settings.resamplesChecked())
|
||||
arguments << "--benchmark-resamples" << QString::number(settings.benchmarkResamples());
|
||||
if (settings.warmupChecked())
|
||||
arguments << "--benchmark-warmup-time" << QString::number(settings.benchmarkWarmupTime());
|
||||
if (settings.confidenceIntervalChecked())
|
||||
arguments << "--benchmark-confidence-interval" << QString::number(settings.confidenceInterval());
|
||||
if (settings.noAnalysis())
|
||||
arguments << "--benchmark-no-analysis";
|
||||
if (settings->showSuccess.value())
|
||||
if (settings.showSuccess())
|
||||
arguments << "-s";
|
||||
if (settings->noThrow.value())
|
||||
if (settings.noThrow())
|
||||
arguments << "-e";
|
||||
if (settings->visibleWhitespace.value())
|
||||
if (settings.visibleWhitespace())
|
||||
arguments << "-i";
|
||||
if (settings->warnOnEmpty.value())
|
||||
if (settings.warnOnEmpty())
|
||||
arguments << "-w" << "NoAssertions";
|
||||
|
||||
if (isDebugRunMode() && settings->breakOnFailure.value())
|
||||
if (isDebugRunMode() && settings.breakOnFailure())
|
||||
arguments << "-b";
|
||||
return arguments;
|
||||
}
|
||||
|
@@ -1,39 +0,0 @@
|
||||
// Copyright (C) 2019 Jochen Seemann
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "catchframework.h"
|
||||
|
||||
#include "catchtestparser.h"
|
||||
#include "catchtreeitem.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
const char *CatchFramework::name() const
|
||||
{
|
||||
return "Catch";
|
||||
}
|
||||
|
||||
QString CatchFramework::displayName() const
|
||||
{
|
||||
return Tr::tr("Catch Test");
|
||||
}
|
||||
|
||||
unsigned CatchFramework::priority() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
ITestParser *CatchFramework::createTestParser()
|
||||
{
|
||||
return new CatchTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *CatchFramework::createRootNode()
|
||||
{
|
||||
return new CatchTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
@@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2019 Jochen Seemann
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "catchtestsettings.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class CatchFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
CatchFramework() : ITestFramework(true) {}
|
||||
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
private:
|
||||
ITestSettings * testSettings() override { return &m_settings; }
|
||||
CatchTestSettings m_settings{settingsId()};
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
@@ -4,7 +4,7 @@
|
||||
#include "catchtestparser.h"
|
||||
|
||||
#include "catchcodeparser.h"
|
||||
#include "catchframework.h"
|
||||
#include "catchtestsettings.h"
|
||||
#include "catchtreeitem.h"
|
||||
|
||||
#include <cppeditor/cppmodelmanager.h>
|
||||
|
@@ -3,9 +3,14 @@
|
||||
|
||||
#include "catchtestsettings.h"
|
||||
|
||||
#include "catchtestparser.h"
|
||||
#include "catchtreeitem.h"
|
||||
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace Layouting;
|
||||
@@ -13,11 +18,15 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
CatchTestSettings::CatchTestSettings(Id settingsId)
|
||||
CatchFramework &theCatchFramework()
|
||||
{
|
||||
static CatchFramework framework;
|
||||
return framework;
|
||||
}
|
||||
|
||||
CatchFramework::CatchFramework()
|
||||
: ITestFramework(true)
|
||||
{
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr("Catch Test"));
|
||||
setSettingsGroups("Autotest", "Catch2");
|
||||
|
||||
setLayouter([this] {
|
||||
@@ -107,4 +116,45 @@ CatchTestSettings::CatchTestSettings(Id settingsId)
|
||||
warnOnEmpty.setToolTip(Tr::tr("Warns if a test section does not check any assertion."));
|
||||
}
|
||||
|
||||
const char *CatchFramework::name() const
|
||||
{
|
||||
return "Catch";
|
||||
}
|
||||
|
||||
QString CatchFramework::displayName() const
|
||||
{
|
||||
return Tr::tr("Catch Test");
|
||||
}
|
||||
|
||||
unsigned CatchFramework::priority() const
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
ITestParser *CatchFramework::createTestParser()
|
||||
{
|
||||
return new CatchTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *CatchFramework::createRootNode()
|
||||
{
|
||||
return new CatchTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
// CatchTestSettingsPage
|
||||
|
||||
class CatchTestSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CatchTestSettingsPage()
|
||||
{
|
||||
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix("12.Catch"));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr("Catch Test"));
|
||||
setSettingsProvider([] { return &theCatchFramework(); });
|
||||
}
|
||||
};
|
||||
|
||||
const CatchTestSettingsPage settingsPage;
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,14 +3,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestframework.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class CatchTestSettings : public Core::PagedSettings
|
||||
class CatchFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
explicit CatchTestSettings(Utils::Id settingsId);
|
||||
CatchFramework();
|
||||
|
||||
Utils::IntegerAspect abortAfter{this};
|
||||
Utils::IntegerAspect benchmarkSamples{this};
|
||||
@@ -28,6 +28,16 @@ public:
|
||||
Utils::BoolAspect noThrow{this};
|
||||
Utils::BoolAspect visibleWhitespace{this};
|
||||
Utils::BoolAspect warnOnEmpty{this};
|
||||
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
CatchFramework &theCatchFramework();
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,9 +3,16 @@
|
||||
|
||||
#include "ctestsettings.h"
|
||||
|
||||
#include "ctesttreeitem.h"
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace Layouting;
|
||||
@@ -13,12 +20,16 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
CTestSettings::CTestSettings(Id settingsId)
|
||||
CTestTool &theCTestTool()
|
||||
{
|
||||
static CTestTool tool;
|
||||
return tool;
|
||||
}
|
||||
|
||||
CTestTool::CTestTool()
|
||||
: Autotest::ITestTool(false)
|
||||
{
|
||||
setSettingsGroups("Autotest", "CTest");
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr("CTest"));
|
||||
|
||||
setLayouter([this] {
|
||||
return Row { Form {
|
||||
@@ -97,7 +108,7 @@ CTestSettings::CTestSettings(Id settingsId)
|
||||
threshold.setEnabler(&testLoad);
|
||||
}
|
||||
|
||||
QStringList CTestSettings::activeSettingsAsOptions() const
|
||||
QStringList CTestTool::activeSettingsAsOptions() const
|
||||
{
|
||||
QStringList options;
|
||||
if (outputOnFail.value())
|
||||
@@ -133,4 +144,47 @@ QStringList CTestSettings::activeSettingsAsOptions() const
|
||||
return options;
|
||||
}
|
||||
|
||||
Id CTestTool::buildSystemId() const
|
||||
{
|
||||
return Id(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
}
|
||||
|
||||
ITestTreeItem *CTestTool::createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci)
|
||||
{
|
||||
CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path, TestTreeItem::TestCase);
|
||||
item->setLine(tci.line);
|
||||
return item;
|
||||
}
|
||||
|
||||
const char *CTestTool::name() const
|
||||
{
|
||||
return "CTest";
|
||||
}
|
||||
|
||||
QString CTestTool::displayName() const
|
||||
{
|
||||
return Tr::tr("CTest");
|
||||
}
|
||||
|
||||
ITestTreeItem *CTestTool::createRootNode()
|
||||
{
|
||||
return new CTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
// CTestToolSettingsPage
|
||||
|
||||
class CTestToolSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CTestToolSettingsPage()
|
||||
{
|
||||
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix(QString("255.CTest")));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr("CTest"));
|
||||
setSettingsProvider([] { return &theCTestTool(); });
|
||||
}
|
||||
};
|
||||
|
||||
const CTestToolSettingsPage settingsPage;
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,14 +3,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestframework.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class CTestSettings : public Core::PagedSettings
|
||||
class CTestTool final : public Autotest::ITestTool
|
||||
{
|
||||
public:
|
||||
explicit CTestSettings(Utils::Id settingsId);
|
||||
CTestTool();
|
||||
|
||||
Utils::Id buildSystemId() const final;
|
||||
|
||||
ITestTreeItem *createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci) final;
|
||||
|
||||
const char *name() const final;
|
||||
QString displayName() const final;
|
||||
ITestTreeItem *createRootNode() final;
|
||||
|
||||
|
||||
QStringList activeSettingsAsOptions() const;
|
||||
|
||||
@@ -28,5 +37,7 @@ public:
|
||||
Utils::IntegerAspect threshold{this};
|
||||
};
|
||||
|
||||
CTestTool &theCTestTool();
|
||||
|
||||
} // Autotest::Internal
|
||||
|
||||
|
@@ -1,43 +0,0 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "ctesttool.h"
|
||||
#include "ctesttreeitem.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
Utils::Id CTestTool::buildSystemId() const
|
||||
{
|
||||
return Utils::Id(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
}
|
||||
|
||||
ITestTreeItem *CTestTool::createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci)
|
||||
{
|
||||
CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path, TestTreeItem::TestCase);
|
||||
item->setLine(tci.line);
|
||||
return item;
|
||||
}
|
||||
|
||||
const char *CTestTool::name() const
|
||||
{
|
||||
return "CTest";
|
||||
}
|
||||
|
||||
QString CTestTool::displayName() const
|
||||
{
|
||||
return Tr::tr("CTest");
|
||||
}
|
||||
|
||||
ITestTreeItem *CTestTool::createRootNode()
|
||||
{
|
||||
return new CTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
@@ -1,31 +0,0 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../itestframework.h"
|
||||
#include "ctestsettings.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class CTestTool final : public Autotest::ITestTool
|
||||
{
|
||||
public:
|
||||
CTestTool() : Autotest::ITestTool(false) {}
|
||||
|
||||
Utils::Id buildSystemId() const final;
|
||||
|
||||
ITestTreeItem *createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci) final;
|
||||
|
||||
protected:
|
||||
const char *name() const final;
|
||||
QString displayName() const final;
|
||||
ITestTreeItem *createRootNode() final;
|
||||
|
||||
private:
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
|
||||
CTestSettings m_settings{settingsId()};
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
@@ -89,7 +89,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi
|
||||
|
||||
const ProjectExplorer::BuildSystem *buildSystem = target->buildSystem();
|
||||
QStringList options{"--timeout", QString::number(testSettings().timeout() / 1000)};
|
||||
auto ctestSettings = static_cast<CTestSettings *>(testBase()->testSettings());
|
||||
auto ctestSettings = static_cast<CTestTool *>(testBase());
|
||||
options << ctestSettings->activeSettingsAsOptions();
|
||||
CommandLine command = buildSystem->commandLineForTests(selected, options);
|
||||
if (command.executable().isEmpty())
|
||||
|
@@ -67,21 +67,19 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
arguments << "--gtest_filter=\"" + testSets.join(':') + '"';
|
||||
}
|
||||
|
||||
auto gSettings = static_cast<GTestSettings *>(framework()->testSettings());
|
||||
if (!gSettings)
|
||||
return arguments;
|
||||
GTestFramework &gSettings = *static_cast<GTestFramework *>(framework());
|
||||
|
||||
if (gSettings->runDisabled.value())
|
||||
if (gSettings.runDisabled())
|
||||
arguments << "--gtest_also_run_disabled_tests";
|
||||
if (gSettings->repeat.value())
|
||||
arguments << QString("--gtest_repeat=%1").arg(gSettings->iterations.value());
|
||||
if (gSettings->shuffle.value())
|
||||
arguments << "--gtest_shuffle" << QString("--gtest_random_seed=%1").arg(gSettings->seed.value());
|
||||
if (gSettings->throwOnFailure.value())
|
||||
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 (isDebugRunMode()) {
|
||||
if (gSettings->breakOnFailure.value())
|
||||
if (gSettings.breakOnFailure())
|
||||
arguments << "--gtest_break_on_failure";
|
||||
arguments << "--gtest_catch_exceptions=0";
|
||||
}
|
||||
|
@@ -1,75 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "gtestframework.h"
|
||||
|
||||
#include "../autotesttr.h"
|
||||
#include "gtesttreeitem.h"
|
||||
#include "gtestparser.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
static GTestSettings *g_settings;
|
||||
|
||||
GTestFramework::GTestFramework()
|
||||
: ITestFramework(true)
|
||||
{
|
||||
g_settings = &m_settings;
|
||||
}
|
||||
|
||||
ITestParser *GTestFramework::createTestParser()
|
||||
{
|
||||
return new GTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *GTestFramework::createRootNode()
|
||||
{
|
||||
return new GTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
{
|
||||
return GTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString GTestFramework:: displayName() const
|
||||
{
|
||||
return Tr::tr(GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned GTestFramework::priority() const
|
||||
{
|
||||
return GTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
QString GTestFramework::currentGTestFilter()
|
||||
{
|
||||
return g_settings->gtestFilter.value();
|
||||
}
|
||||
|
||||
QString GTestFramework::groupingToolTip() const
|
||||
{
|
||||
return Tr::tr("Enable or disable grouping of test cases by folder or "
|
||||
"GTest filter.\nSee also Google Test settings.");
|
||||
}
|
||||
|
||||
GTest::Constants::GroupMode GTestFramework::groupMode()
|
||||
{
|
||||
return GTest::Constants::GroupMode(g_settings->groupMode.itemValue().toInt());
|
||||
}
|
||||
|
||||
QStringList GTestFramework::testNameForSymbolName(const QString &symbolName) const
|
||||
{
|
||||
static const QRegularExpression r("^(.+::)?((DISABLED_)?.+?)_((DISABLED_)?.+)_Test::TestBody$");
|
||||
const QRegularExpressionMatch match = r.match(symbolName);
|
||||
if (!match.hasMatch())
|
||||
return {};
|
||||
|
||||
return { match.captured(2), match.captured(4) };
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
@@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../itestframework.h"
|
||||
#include "gtestconstants.h"
|
||||
#include "gtestsettings.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class GTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
GTestFramework();
|
||||
|
||||
static GTest::Constants::GroupMode groupMode();
|
||||
static QString currentGTestFilter();
|
||||
|
||||
QStringList testNameForSymbolName(const QString &symbolName) const override;
|
||||
private:
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
QString groupingToolTip() const override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
|
||||
GTestSettings m_settings{settingsId()};
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
@@ -4,11 +4,17 @@
|
||||
#include "gtestsettings.h"
|
||||
|
||||
#include "gtest_utils.h"
|
||||
#include "gtesttreeitem.h"
|
||||
#include "gtestparser.h"
|
||||
#include "gtestconstants.h"
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
#include "../testtreemodel.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace Layouting;
|
||||
@@ -16,12 +22,16 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
GTestSettings::GTestSettings(Id settingsId)
|
||||
GTestFramework &theGTestFramework()
|
||||
{
|
||||
static GTestFramework framework;
|
||||
return framework;
|
||||
}
|
||||
|
||||
GTestFramework::GTestFramework()
|
||||
: ITestFramework(true)
|
||||
{
|
||||
setSettingsGroups("Autotest", "GTest");
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
|
||||
setLayouter([this] {
|
||||
return Row { Form {
|
||||
@@ -112,15 +122,83 @@ GTestSettings::GTestSettings(Id settingsId)
|
||||
return edit && GTestUtils::isValidGTestFilter(edit->text());
|
||||
});
|
||||
|
||||
QObject::connect(&groupMode, &SelectionAspect::volatileValueChanged, >estFilter, [this] {
|
||||
connect(&groupMode, &SelectionAspect::volatileValueChanged, >estFilter, [this] {
|
||||
gtestFilter.setEnabled(groupMode.itemValueForIndex(groupMode.volatileValue())
|
||||
== GTest::Constants::GTestFilter);
|
||||
});
|
||||
|
||||
QObject::connect(this, &AspectContainer::applied, this, [] {
|
||||
connect(this, &AspectContainer::applied, this, [] {
|
||||
Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME);
|
||||
TestTreeModel::instance()->rebuild({id});
|
||||
});
|
||||
}
|
||||
|
||||
ITestParser *GTestFramework::createTestParser()
|
||||
{
|
||||
return new GTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *GTestFramework::createRootNode()
|
||||
{
|
||||
return new GTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
{
|
||||
return GTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString GTestFramework::displayName() const
|
||||
{
|
||||
return Tr::tr(GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned GTestFramework::priority() const
|
||||
{
|
||||
return GTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
QString GTestFramework::currentGTestFilter()
|
||||
{
|
||||
return theGTestFramework().gtestFilter();
|
||||
}
|
||||
|
||||
QString GTestFramework::groupingToolTip() const
|
||||
{
|
||||
return Tr::tr("Enable or disable grouping of test cases by folder or "
|
||||
"GTest filter.\nSee also Google Test settings.");
|
||||
}
|
||||
|
||||
GTest::Constants::GroupMode GTestFramework::staticGroupMode()
|
||||
{
|
||||
return GTest::Constants::GroupMode(theGTestFramework().groupMode.itemValue().toInt());
|
||||
}
|
||||
|
||||
QStringList GTestFramework::testNameForSymbolName(const QString &symbolName) const
|
||||
{
|
||||
static const QRegularExpression r("^(.+::)?((DISABLED_)?.+?)_((DISABLED_)?.+)_Test::TestBody$");
|
||||
const QRegularExpressionMatch match = r.match(symbolName);
|
||||
if (!match.hasMatch())
|
||||
return {};
|
||||
|
||||
return { match.captured(2), match.captured(4) };
|
||||
}
|
||||
|
||||
// GTestSettingPage
|
||||
|
||||
class GTestSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
GTestSettingsPage()
|
||||
{
|
||||
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix(QString("%1.%2")
|
||||
.arg(GTest::Constants::FRAMEWORK_PRIORITY)
|
||||
.arg(GTest::Constants::FRAMEWORK_NAME)));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setSettingsProvider([] { return &theGTestFramework(); });
|
||||
}
|
||||
};
|
||||
|
||||
const GTestSettingsPage settingsPage;
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,14 +3,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "gtestconstants.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class GTestSettings : public Core::PagedSettings
|
||||
class GTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
explicit GTestSettings(Utils::Id settingsId);
|
||||
GTestFramework();
|
||||
|
||||
Utils::IntegerAspect iterations{this};
|
||||
Utils::IntegerAspect seed{this};
|
||||
@@ -21,6 +23,20 @@ public:
|
||||
Utils::BoolAspect breakOnFailure{this};
|
||||
Utils::SelectionAspect groupMode{this};
|
||||
Utils::StringAspect gtestFilter{this};
|
||||
|
||||
static GTest::Constants::GroupMode staticGroupMode();
|
||||
static QString currentGTestFilter();
|
||||
|
||||
QStringList testNameForSymbolName(const QString &symbolName) const override;
|
||||
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
QString groupingToolTip() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
GTestFramework &theGTestFramework();
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "gtestconfiguration.h"
|
||||
#include "gtestconstants.h"
|
||||
#include "gtestframework.h"
|
||||
#include "gtestsettings.h"
|
||||
#include "gtestparser.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
@@ -113,7 +113,7 @@ QVariant GTestTreeItem::data(int column, int role) const
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
if (type() == GroupNode
|
||||
&& GTestFramework::groupMode() == GTest::Constants::GTestFilter) {
|
||||
&& GTestFramework::staticGroupMode() == GTest::Constants::GTestFilter) {
|
||||
static const QIcon filterIcon = Icon({{":/utils/images/filtericon.png",
|
||||
Theme::PanelTextColorMid}}).icon();
|
||||
return filterIcon;
|
||||
@@ -121,7 +121,7 @@ QVariant GTestTreeItem::data(int column, int role) const
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
if (type() == GroupNode
|
||||
&& GTestFramework::groupMode() == GTest::Constants::GTestFilter) {
|
||||
&& GTestFramework::staticGroupMode() == GTest::Constants::GTestFilter) {
|
||||
const auto tpl = QString("<p>%1</p><p>%2</p>").arg(filePath().toString());
|
||||
return tpl.arg(Tr::tr("Change GTest filter in use inside the settings."));
|
||||
}
|
||||
@@ -361,7 +361,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (result->framework->grouping()) {
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
if (GTestFramework::staticGroupMode() == GTest::Constants::Directory) {
|
||||
const FilePath base = parseResult->fileName.absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
GTestTreeItem *group = static_cast<GTestTreeItem *>(childAt(row));
|
||||
@@ -445,7 +445,7 @@ bool GTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
if (GTestFramework::staticGroupMode() == GTest::Constants::Directory) {
|
||||
const FilePath &absPath = filePath().absolutePath();
|
||||
return new GTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||
} else { // GTestFilter
|
||||
@@ -531,7 +531,7 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
if (type() != TestTreeItem::GroupNode)
|
||||
return false;
|
||||
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
if (GTestFramework::staticGroupMode() == GTest::Constants::Directory) {
|
||||
return other->filePath().absolutePath() == filePath();
|
||||
} else { // GTestFilter
|
||||
QString fullName;
|
||||
@@ -566,7 +566,7 @@ TestTreeItem *GTestTreeItem::applyFilters()
|
||||
if (type() != TestSuite)
|
||||
return nullptr;
|
||||
|
||||
if (GTestFramework::groupMode() != GTest::Constants::GTestFilter)
|
||||
if (GTestFramework::staticGroupMode() != GTest::Constants::GTestFilter)
|
||||
return nullptr;
|
||||
|
||||
const QString gtestFilter = GTestFramework::currentGTestFilter();
|
||||
|
@@ -17,12 +17,6 @@ ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
||||
, m_type(type)
|
||||
{}
|
||||
|
||||
Id ITestBase::settingsId() const
|
||||
{
|
||||
return Id(Constants::SETTINGSPAGE_PREFIX)
|
||||
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
||||
}
|
||||
|
||||
Id ITestBase::id() const
|
||||
{
|
||||
return Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
||||
@@ -41,7 +35,9 @@ void ITestBase::resetRootNode()
|
||||
|
||||
ITestFramework::ITestFramework(bool activeByDefault)
|
||||
: ITestBase(activeByDefault, ITestBase::Framework)
|
||||
{}
|
||||
{
|
||||
setAutoApply(false);
|
||||
}
|
||||
|
||||
ITestFramework::~ITestFramework()
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
namespace ProjectExplorer { struct TestCaseInfo; }
|
||||
@@ -12,12 +13,11 @@ namespace Autotest {
|
||||
|
||||
class ITestFramework;
|
||||
class ITestParser;
|
||||
using ITestSettings = Utils::AspectContainer;
|
||||
class ITestTool;
|
||||
class ITestTreeItem;
|
||||
class TestTreeItem;
|
||||
|
||||
class ITestBase
|
||||
class ITestBase : public Utils::AspectContainer
|
||||
{
|
||||
public:
|
||||
enum TestBaseType
|
||||
@@ -35,9 +35,6 @@ public:
|
||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||
TestBaseType type() const { return m_type; }
|
||||
|
||||
virtual ITestSettings *testSettings() { return nullptr; }
|
||||
|
||||
Utils::Id settingsId() const;
|
||||
Utils::Id id() const;
|
||||
|
||||
bool active() const { return m_active; }
|
||||
|
@@ -29,8 +29,8 @@ static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode)
|
||||
|
||||
TestOutputReader *QtTestConfiguration::createOutputReader(Process *app) const
|
||||
{
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
||||
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings.useXMLOutput()
|
||||
? QtTestOutputReader::XML
|
||||
: QtTestOutputReader::PlainText;
|
||||
return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QtTest);
|
||||
@@ -44,29 +44,27 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
|
||||
runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
|
||||
omitted, false));
|
||||
}
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
if (!qtSettings)
|
||||
return arguments;
|
||||
if (qtSettings->useXMLOutput.value())
|
||||
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework());
|
||||
if (qtSettings.useXMLOutput())
|
||||
arguments << "-xml";
|
||||
if (!testCases().isEmpty())
|
||||
arguments << quoteIfNeeded(testCases(), isDebugRunMode());
|
||||
|
||||
const QString &metricsOption = QtTestSettings::metricsTypeToOption(MetricsType(qtSettings->metrics.value()));
|
||||
const QString metricsOption = QtTestFramework::metricsTypeToOption(MetricsType(qtSettings.metrics()));
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
|
||||
if (qtSettings->verboseBench.value())
|
||||
if (qtSettings.verboseBench())
|
||||
arguments << "-vb";
|
||||
|
||||
if (qtSettings->logSignalsSlots.value())
|
||||
if (qtSettings.logSignalsSlots())
|
||||
arguments << "-vs";
|
||||
|
||||
if (isDebugRunMode() && qtSettings->noCrashHandler.value())
|
||||
if (isDebugRunMode() && qtSettings.noCrashHandler())
|
||||
arguments << "-nocrashhandler";
|
||||
|
||||
if (qtSettings->limitWarnings.value() && qtSettings->maxWarnings.value() != 2000)
|
||||
arguments << "-maxwarnings" << QString::number(qtSettings->maxWarnings.value());
|
||||
if (qtSettings.limitWarnings() && qtSettings.maxWarnings() != 2000)
|
||||
arguments << "-maxwarnings" << QString::number(qtSettings.maxWarnings());
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
@@ -1,48 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qttestframework.h"
|
||||
|
||||
#include "qttestconstants.h"
|
||||
#include "qttestparser.h"
|
||||
#include "qttesttreeitem.h"
|
||||
#include "../autotesttr.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
ITestParser *QtTestFramework::createTestParser()
|
||||
{
|
||||
return new QtTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *QtTestFramework::createRootNode()
|
||||
{
|
||||
return new QtTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
{
|
||||
return QtTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString QtTestFramework::displayName() const
|
||||
{
|
||||
return Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned QtTestFramework::priority() const
|
||||
{
|
||||
return QtTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
QStringList QtTestFramework::testNameForSymbolName(const QString &symbolName) const
|
||||
{
|
||||
int index = symbolName.lastIndexOf("::");
|
||||
if (index == -1)
|
||||
return {};
|
||||
return { symbolName.left(index), symbolName.mid(index + 2) };
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
@@ -1,29 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "qttestsettings.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class QtTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
QtTestFramework() : ITestFramework(true) {}
|
||||
|
||||
QStringList testNameForSymbolName(const QString &symbolName) const override;
|
||||
private:
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
ITestSettings *testSettings() override { return &m_settings; }
|
||||
|
||||
QtTestSettings m_settings{settingsId()};
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
@@ -6,6 +6,10 @@
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
#include "qttestconstants.h"
|
||||
#include "qttestparser.h"
|
||||
#include "qttesttreeitem.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
@@ -15,12 +19,15 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
QtTestSettings::QtTestSettings(Id settingsId)
|
||||
QtTestFramework &theQtTestFramework()
|
||||
{
|
||||
static QtTestFramework framework;
|
||||
return framework;
|
||||
}
|
||||
|
||||
QtTestFramework::QtTestFramework() : ITestFramework(true)
|
||||
{
|
||||
setSettingsGroups("Autotest", "QtTest");
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
|
||||
setLayouter([this] {
|
||||
return Row { Form {
|
||||
@@ -91,7 +98,7 @@ QtTestSettings::QtTestSettings(Id settingsId)
|
||||
"feature significantly increases scan time."));
|
||||
}
|
||||
|
||||
QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
QString QtTestFramework::metricsTypeToOption(const MetricsType type)
|
||||
{
|
||||
switch (type) {
|
||||
case MetricsType::Walltime:
|
||||
@@ -108,4 +115,55 @@ QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
return {};
|
||||
}
|
||||
|
||||
ITestParser *QtTestFramework::createTestParser()
|
||||
{
|
||||
return new QtTestParser(this);
|
||||
}
|
||||
|
||||
ITestTreeItem *QtTestFramework::createRootNode()
|
||||
{
|
||||
return new QtTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
{
|
||||
return QtTest::Constants::FRAMEWORK_NAME;
|
||||
}
|
||||
|
||||
QString QtTestFramework::displayName() const
|
||||
{
|
||||
return Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
unsigned QtTestFramework::priority() const
|
||||
{
|
||||
return QtTest::Constants::FRAMEWORK_PRIORITY;
|
||||
}
|
||||
|
||||
QStringList QtTestFramework::testNameForSymbolName(const QString &symbolName) const
|
||||
{
|
||||
int index = symbolName.lastIndexOf("::");
|
||||
if (index == -1)
|
||||
return {};
|
||||
return { symbolName.left(index), symbolName.mid(index + 2) };
|
||||
}
|
||||
|
||||
// QtTestSettingsPage
|
||||
|
||||
class QtTestSettingPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
QtTestSettingPage()
|
||||
{
|
||||
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix(QString("%1.%2")
|
||||
.arg(QtTest::Constants::FRAMEWORK_PRIORITY)
|
||||
.arg(QtTest::Constants::FRAMEWORK_NAME)));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(Tr::tr(QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setSettingsProvider([] { return &theQtTestFramework(); });
|
||||
}
|
||||
};
|
||||
|
||||
const QtTestSettingPage settingsPage;
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestframework.h"
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
@@ -16,10 +16,10 @@ enum MetricsType
|
||||
Perf
|
||||
};
|
||||
|
||||
class QtTestSettings : public Core::PagedSettings
|
||||
class QtTestFramework : public ITestFramework
|
||||
{
|
||||
public:
|
||||
explicit QtTestSettings(Utils::Id settingsId);
|
||||
QtTestFramework();
|
||||
|
||||
static QString metricsTypeToOption(const MetricsType type);
|
||||
|
||||
@@ -31,6 +31,16 @@ public:
|
||||
Utils::BoolAspect limitWarnings{this};
|
||||
Utils::IntegerAspect maxWarnings{this};
|
||||
Utils::BoolAspect quickCheckForDerivedTests{this};
|
||||
|
||||
QStringList testNameForSymbolName(const QString &symbolName) const override;
|
||||
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
QtTestFramework &theQtTestFramework();
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -22,8 +22,8 @@ QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework)
|
||||
|
||||
TestOutputReader *QuickTestConfiguration::createOutputReader(Process *app) const
|
||||
{
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
||||
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings.useXMLOutput()
|
||||
? QtTestOutputReader::XML
|
||||
: QtTestOutputReader::PlainText;
|
||||
return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QuickTest);
|
||||
@@ -38,25 +38,23 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
||||
omitted, true));
|
||||
}
|
||||
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
if (!qtSettings)
|
||||
return arguments;
|
||||
if (qtSettings->useXMLOutput.value())
|
||||
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework());
|
||||
if (qtSettings.useXMLOutput())
|
||||
arguments << "-xml";
|
||||
if (!testCases().isEmpty())
|
||||
arguments << testCases();
|
||||
|
||||
const QString &metricsOption = QtTestSettings::metricsTypeToOption(MetricsType(qtSettings->metrics.value()));
|
||||
const QString &metricsOption = QtTestFramework::metricsTypeToOption(MetricsType(qtSettings.metrics()));
|
||||
if (!metricsOption.isEmpty())
|
||||
arguments << metricsOption;
|
||||
|
||||
if (isDebugRunMode()) {
|
||||
if (qtSettings->noCrashHandler.value())
|
||||
if (qtSettings.noCrashHandler())
|
||||
arguments << "-nocrashhandler";
|
||||
}
|
||||
|
||||
if (qtSettings->limitWarnings.value() && qtSettings->maxWarnings.value() != 2000)
|
||||
arguments << "-maxwarnings" << QString::number(qtSettings->maxWarnings.value());
|
||||
if (qtSettings.limitWarnings() && qtSettings.maxWarnings() != 2000)
|
||||
arguments << "-maxwarnings" << QString::number(qtSettings.maxWarnings());
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
@@ -5,14 +5,17 @@
|
||||
#include "quicktestparser.h"
|
||||
#include "quicktesttreeitem.h"
|
||||
|
||||
#include "../autotestconstants.h"
|
||||
#include "../autotesttr.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
#include "../qtest/qttestconstants.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QuickTestFramework &theQuickTestFramework()
|
||||
{
|
||||
static QuickTestFramework framework;
|
||||
return framework;
|
||||
}
|
||||
|
||||
ITestParser *QuickTestFramework::createTestParser()
|
||||
{
|
||||
return new QuickTestParser(this);
|
||||
@@ -38,13 +41,5 @@ unsigned QuickTestFramework::priority() const
|
||||
return 5;
|
||||
}
|
||||
|
||||
ITestSettings *QuickTestFramework::testSettings()
|
||||
{
|
||||
static const Utils::Id id
|
||||
= Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
ITestFramework *qtTestFramework = TestFrameworkManager::frameworkForId(id);
|
||||
return qtTestFramework->testSettings();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "../qtest/qttestsettings.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace QuickTest {
|
||||
namespace Constants {
|
||||
@@ -16,19 +18,20 @@ const char FRAMEWORK_NAME[] = "QtQuickTest";
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QuickTestFramework : public ITestFramework
|
||||
class QuickTestFramework : public QtTestFramework
|
||||
{
|
||||
public:
|
||||
QuickTestFramework() : ITestFramework(true) {}
|
||||
QuickTestFramework() {}
|
||||
const char *name() const override;
|
||||
QString displayName() const override;
|
||||
unsigned priority() const override;
|
||||
ITestSettings *testSettings() override;
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
ITestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
QuickTestFramework &theQuickTestFramework();
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
@@ -356,8 +356,8 @@ void QuickTestParser::init(const QSet<FilePath> &filesToParse, bool fullParse)
|
||||
m_mainCppFiles.clear();
|
||||
}
|
||||
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
m_checkForDerivedTests = qtSettings->quickCheckForDerivedTests.value();
|
||||
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework());
|
||||
m_checkForDerivedTests = qtSettings.quickCheckForDerivedTests();
|
||||
|
||||
CppParser::init(filesToParse, fullParse);
|
||||
}
|
||||
|
@@ -22,8 +22,6 @@ TestFrameworkManager::TestFrameworkManager()
|
||||
|
||||
TestFrameworkManager::~TestFrameworkManager()
|
||||
{
|
||||
qDeleteAll(m_registeredFrameworks);
|
||||
qDeleteAll(m_registeredTestTools);
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
@@ -96,14 +94,11 @@ ITestTool *TestFrameworkManager::testToolForBuildSystemId(Id buildSystemId)
|
||||
void TestFrameworkManager::synchronizeSettings()
|
||||
{
|
||||
Internal::testSettings().fromSettings();
|
||||
for (ITestFramework *framework : std::as_const(m_registeredFrameworks)) {
|
||||
if (ITestSettings *fSettings = framework->testSettings())
|
||||
fSettings->readSettings();
|
||||
}
|
||||
for (ITestTool *testTool : std::as_const(m_registeredTestTools)) {
|
||||
if (ITestSettings *tSettings = testTool->testSettings())
|
||||
tSettings->readSettings();
|
||||
}
|
||||
for (ITestFramework *framework : std::as_const(m_registeredFrameworks))
|
||||
framework->readSettings();
|
||||
|
||||
for (ITestTool *testTool : std::as_const(m_registeredTestTools))
|
||||
testTool->readSettings();
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
Reference in New Issue
Block a user