forked from qt-creator/qt-creator
Autotest: Keep track of generating framework in TestTreeItem
... and TestConfiguration. This allows dropping code that reconstruct framework ids and framework lookup by id. Change-Id: I0bb1e6e135376e21f96b9fab7971aa097787e483 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -29,24 +29,16 @@
|
||||
#include "boosttestsettings.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
static BoostTestSettings *getBoostSettings()
|
||||
{
|
||||
const Core::Id id = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(
|
||||
BoostTest::Constants::FRAMEWORK_NAME);
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
return dynamic_cast<BoostTestSettings *>(manager->settingsForTestFramework(id));
|
||||
}
|
||||
|
||||
TestOutputReader *BoostTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const
|
||||
{
|
||||
auto settings = getBoostSettings();
|
||||
auto settings = dynamic_cast<BoostTestSettings *>(framework()->frameworkSettings());
|
||||
return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(),
|
||||
settings->logLevel, settings->reportLevel);
|
||||
}
|
||||
@@ -113,7 +105,7 @@ static QStringList filterInterfering(const QStringList &provided, QStringList *o
|
||||
|
||||
QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
auto boostSettings = getBoostSettings();
|
||||
auto boostSettings = dynamic_cast<BoostTestSettings *>(framework()->frameworkSettings());
|
||||
QStringList arguments;
|
||||
arguments << "-l" << BoostTestSettings::logLevelToOption(boostSettings->logLevel);
|
||||
arguments << "-r" << BoostTestSettings::reportLevelToOption(boostSettings->reportLevel);
|
||||
|
@@ -33,7 +33,8 @@ namespace Internal {
|
||||
class BoostTestConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
BoostTestConfiguration() {}
|
||||
explicit BoostTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
|
@@ -37,9 +37,10 @@ ITestParser *BoostTestFramework::createTestParser()
|
||||
return new BoostTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *BoostTestFramework::createRootNode() const
|
||||
TestTreeItem *BoostTestFramework::createRootNode()
|
||||
{
|
||||
return new BoostTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("BoostTestFramework",
|
||||
BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
|
@@ -43,7 +43,7 @@ private:
|
||||
unsigned priority() const override;
|
||||
IFrameworkSettings *frameworkSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() const override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
|
||||
BoostTestSettings m_settings;
|
||||
BoostTestSettingsPage m_settingsPage{&m_settings, settingsId()};
|
||||
|
@@ -56,7 +56,7 @@ TestTreeItem *BoostTestParseResult::createTestTreeItem() const
|
||||
if (itemType == TestTreeItem::Root)
|
||||
return nullptr;
|
||||
|
||||
BoostTestTreeItem *item = new BoostTestTreeItem(displayName, fileName, itemType);
|
||||
BoostTestTreeItem *item = new BoostTestTreeItem(framework, displayName, fileName, itemType);
|
||||
item->setProFile(proFile);
|
||||
item->setLine(line);
|
||||
item->setColumn(column);
|
||||
|
@@ -40,7 +40,7 @@ namespace Internal {
|
||||
|
||||
TestTreeItem *BoostTestTreeItem::copyWithoutChildren()
|
||||
{
|
||||
BoostTestTreeItem *copied = new BoostTestTreeItem;
|
||||
BoostTestTreeItem *copied = new BoostTestTreeItem(framework());
|
||||
copied->copyBasicDataFrom(this);
|
||||
copied->m_state = m_state;
|
||||
copied->m_fullName = m_fullName;
|
||||
@@ -146,7 +146,7 @@ TestTreeItem *BoostTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new BoostTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
return new BoostTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
QString BoostTestTreeItem::prependWithParentsSuitePaths(const QString &testName) const
|
||||
@@ -204,7 +204,7 @@ QList<TestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const
|
||||
|
||||
for (auto it = testsPerProjectfile.begin(), end = testsPerProjectfile.end(); it != end; ++it) {
|
||||
for (const QString &target : qAsConst(it.value().internalTargets)) {
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration;
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration(framework());
|
||||
config->setProject(project);
|
||||
config->setProjectFile(it.key());
|
||||
config->setTestCaseCount(it.value().testCases);
|
||||
@@ -250,7 +250,7 @@ QList<TestConfiguration *> BoostTestTreeItem::getSelectedTestConfigurations() co
|
||||
auto end = testCasesForProjectFile.cend();
|
||||
for (auto it = testCasesForProjectFile.cbegin(); it != end; ++it) {
|
||||
for (const QString &target : it.value().internalTargets) {
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration;
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration(framework());
|
||||
config->setProject(project);
|
||||
config->setProjectFile(it.key());
|
||||
config->setTestCases(it.value().testCases);
|
||||
@@ -294,7 +294,7 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const
|
||||
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(tcName)));
|
||||
}
|
||||
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration;
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration(framework());
|
||||
config->setProjectFile(proFile());
|
||||
config->setProject(project);
|
||||
config->setTestCases(testCases);
|
||||
|
@@ -48,8 +48,12 @@ public:
|
||||
Q_FLAGS(TestState)
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit BoostTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
Type type = Root) : TestTreeItem(name, filePath, type) {}
|
||||
explicit BoostTestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(framework, name, filePath, type)
|
||||
{}
|
||||
|
||||
public:
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#include "gtestoutputreader.h"
|
||||
#include "gtestsettings.h"
|
||||
#include "../autotestplugin.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -73,9 +73,6 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted)
|
||||
|
||||
QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments << filterInterfering(runnable().commandLineArguments.split(
|
||||
@@ -86,8 +83,7 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
if (!testSets.isEmpty())
|
||||
arguments << "--gtest_filter=" + testSets.join(':');
|
||||
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto gSettings = dynamic_cast<GTestSettings *>(manager->settingsForTestFramework(id));
|
||||
auto gSettings = dynamic_cast<GTestSettings *>(framework()->frameworkSettings());
|
||||
if (!gSettings)
|
||||
return arguments;
|
||||
|
||||
|
@@ -33,7 +33,9 @@ namespace Internal {
|
||||
class GTestConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
explicit GTestConfiguration() {}
|
||||
explicit GTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
|
@@ -44,9 +44,10 @@ ITestParser *GTestFramework::createTestParser()
|
||||
return new GTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *GTestFramework::createRootNode() const
|
||||
TestTreeItem *GTestFramework::createRootNode()
|
||||
{
|
||||
return new GTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("GTestFramework",
|
||||
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
|
@@ -47,7 +47,7 @@ private:
|
||||
QString groupingToolTip() const override;
|
||||
IFrameworkSettings *frameworkSettings() override { return &m_settings; }
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() const override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
|
||||
GTestSettings m_settings;
|
||||
GTestSettingsPage m_settingsPage{&m_settings, settingsId()};
|
||||
|
@@ -32,8 +32,6 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class GTestResult;
|
||||
|
||||
class GTestOutputReader : public TestOutputReader
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::GTestOutputReader)
|
||||
|
@@ -38,7 +38,7 @@ TestTreeItem *GTestParseResult::createTestTreeItem() const
|
||||
{
|
||||
if (itemType != TestTreeItem::TestSuite && itemType != TestTreeItem::TestCase)
|
||||
return nullptr;
|
||||
GTestTreeItem *item = new GTestTreeItem(name, fileName, itemType);
|
||||
GTestTreeItem *item = new GTestTreeItem(framework, name, fileName, itemType);
|
||||
item->setProFile(proFile);
|
||||
item->setLine(line);
|
||||
item->setColumn(column);
|
||||
|
@@ -65,7 +65,7 @@ static QString gtestFilter(GTestTreeItem::TestStates states)
|
||||
|
||||
TestTreeItem *GTestTreeItem::copyWithoutChildren()
|
||||
{
|
||||
GTestTreeItem *copied = new GTestTreeItem;
|
||||
GTestTreeItem *copied = new GTestTreeItem(framework());
|
||||
copied->copyBasicDataFrom(this);
|
||||
copied->m_state = m_state;
|
||||
return copied;
|
||||
@@ -170,7 +170,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
|
||||
case TestSuite: {
|
||||
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*');
|
||||
if (int count = childCount()) {
|
||||
config = new GTestConfiguration;
|
||||
config = new GTestConfiguration(framework());
|
||||
config->setTestCases(QStringList(testSpecifier));
|
||||
config->setTestCaseCount(count);
|
||||
config->setProjectFile(proFile());
|
||||
@@ -183,7 +183,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
|
||||
if (!parent)
|
||||
return nullptr;
|
||||
const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name());
|
||||
config = new GTestConfiguration;
|
||||
config = new GTestConfiguration(framework());
|
||||
config->setTestCases(QStringList(testSpecifier));
|
||||
config->setProjectFile(proFile());
|
||||
config->setProject(project);
|
||||
@@ -261,7 +261,7 @@ QList<TestConfiguration *> GTestTreeItem::getTestConfigurations(bool ignoreCheck
|
||||
|
||||
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
||||
for (const QString &target : qAsConst(it.value().internalTargets)) {
|
||||
GTestConfiguration *tc = new GTestConfiguration;
|
||||
GTestConfiguration *tc = new GTestConfiguration(framework());
|
||||
if (!ignoreCheckState)
|
||||
tc->setTestCases(it.value().filters);
|
||||
tc->setTestCaseCount(tc->testCaseCount() + it.value().testSetCount);
|
||||
@@ -307,7 +307,7 @@ QList<TestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const Uti
|
||||
});
|
||||
for (auto it = testCases.begin(), end = testCases.end(); it != end; ++it) {
|
||||
for (const QString &target : qAsConst(it.value().internalTargets)) {
|
||||
GTestConfiguration *tc = new GTestConfiguration;
|
||||
GTestConfiguration *tc = new GTestConfiguration(framework());
|
||||
tc->setTestCases(it.value().filters);
|
||||
tc->setProjectFile(it.key());
|
||||
tc->setProject(project);
|
||||
@@ -420,7 +420,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new GTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
return new GTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
} else { // GTestFilter
|
||||
QTC_ASSERT(childCount(), return nullptr); // paranoia
|
||||
const TestTreeItem *firstChild = childAt(0);
|
||||
@@ -428,7 +428,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||
const QString fullTestName = name() + '.' + firstChild->name();
|
||||
const QString groupNodeName =
|
||||
matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString();
|
||||
auto groupNode = new GTestTreeItem(groupNodeName, activeFilter, TestTreeItem::GroupNode);
|
||||
auto groupNode = new GTestTreeItem(framework(), groupNodeName, activeFilter, TestTreeItem::GroupNode);
|
||||
if (groupNodeName == notMatchingString())
|
||||
groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole);
|
||||
return groupNode;
|
||||
|
@@ -46,8 +46,12 @@ public:
|
||||
Q_FLAGS(TestState)
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit GTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {}
|
||||
explicit GTestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(framework, name, filePath, type), m_state(Enabled)
|
||||
{}
|
||||
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
QVariant data(int column, int role) const override;
|
||||
|
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual ITestParser *createTestParser() = 0;
|
||||
virtual TestTreeItem *createRootNode() const = 0;
|
||||
virtual TestTreeItem *createRootNode() = 0;
|
||||
|
||||
private:
|
||||
TestTreeItem *m_rootNode = nullptr;
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include "qttestsettings.h"
|
||||
#include "qttest_utils.h"
|
||||
#include "../autotestplugin.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
namespace Autotest {
|
||||
@@ -38,10 +38,7 @@ namespace Internal {
|
||||
TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(manager->settingsForTestFramework(id));
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(framework()->frameworkSettings());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput
|
||||
? QtTestOutputReader::XML
|
||||
: QtTestOutputReader::PlainText;
|
||||
@@ -50,17 +47,13 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestR
|
||||
|
||||
QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments.append(QTestUtils::filterInterfering(
|
||||
runnable().commandLineArguments.split(' ', QString::SkipEmptyParts),
|
||||
omitted, false));
|
||||
}
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(manager->settingsForTestFramework(id));
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(framework()->frameworkSettings());
|
||||
if (!qtSettings)
|
||||
return arguments;
|
||||
if (qtSettings->useXMLOutput)
|
||||
|
@@ -33,7 +33,8 @@ namespace Internal {
|
||||
class QtTestConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
explicit QtTestConfiguration() {}
|
||||
explicit QtTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
|
@@ -36,9 +36,10 @@ ITestParser *QtTestFramework::createTestParser()
|
||||
return new QtTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *QtTestFramework::createRootNode() const
|
||||
TestTreeItem *QtTestFramework::createRootNode()
|
||||
{
|
||||
return new QtTestTreeItem(
|
||||
this,
|
||||
QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), TestTreeItem::Root);
|
||||
|
@@ -42,7 +42,7 @@ private:
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() const override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
IFrameworkSettings *frameworkSettings() override { return &m_settings; }
|
||||
|
||||
QtTestSettings m_settings;
|
||||
|
@@ -41,7 +41,7 @@ TestTreeItem *QtTestParseResult::createTestTreeItem() const
|
||||
if (itemType == TestTreeItem::Root)
|
||||
return nullptr;
|
||||
|
||||
QtTestTreeItem *item = new QtTestTreeItem(displayName, fileName, itemType);
|
||||
QtTestTreeItem *item = new QtTestTreeItem(framework, displayName, fileName, itemType);
|
||||
item->setProFile(proFile);
|
||||
item->setLine(line);
|
||||
item->setColumn(column);
|
||||
|
@@ -34,8 +34,9 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QtTestTreeItem::QtTestTreeItem(const QString &name, const QString &filePath, TestTreeItem::Type type)
|
||||
: TestTreeItem(name, filePath, type)
|
||||
QtTestTreeItem::QtTestTreeItem(ITestFramework *framework, const QString &name,
|
||||
const QString &filePath, TestTreeItem::Type type)
|
||||
: TestTreeItem(framework, name, filePath, type)
|
||||
{
|
||||
if (type == TestDataTag)
|
||||
setData(0, Qt::Checked, Qt::CheckStateRole);
|
||||
@@ -43,7 +44,7 @@ QtTestTreeItem::QtTestTreeItem(const QString &name, const QString &filePath, Tes
|
||||
|
||||
TestTreeItem *QtTestTreeItem::copyWithoutChildren()
|
||||
{
|
||||
QtTestTreeItem *copied = new QtTestTreeItem;
|
||||
QtTestTreeItem *copied = new QtTestTreeItem(framework());
|
||||
copied->copyBasicDataFrom(this);
|
||||
copied->m_inherited = m_inherited;
|
||||
return copied;
|
||||
@@ -114,14 +115,14 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
|
||||
QtTestConfiguration *config = nullptr;
|
||||
switch (type()) {
|
||||
case TestCase:
|
||||
config = new QtTestConfiguration;
|
||||
config = new QtTestConfiguration(framework());
|
||||
config->setTestCaseCount(childCount());
|
||||
config->setProjectFile(proFile());
|
||||
config->setProject(project);
|
||||
break;
|
||||
case TestFunction: {
|
||||
TestTreeItem *parent = parentItem();
|
||||
config = new QtTestConfiguration();
|
||||
config = new QtTestConfiguration(framework());
|
||||
config->setTestCases(QStringList(name()));
|
||||
config->setProjectFile(parent->proFile());
|
||||
config->setProject(project);
|
||||
@@ -133,7 +134,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
|
||||
if (!parent)
|
||||
return nullptr;
|
||||
const QString functionWithTag = function->name() + ':' + name();
|
||||
config = new QtTestConfiguration();
|
||||
config = new QtTestConfiguration(framework());
|
||||
config->setTestCases(QStringList(functionWithTag));
|
||||
config->setProjectFile(parent->proFile());
|
||||
config->setProject(project);
|
||||
@@ -180,7 +181,7 @@ static void fillTestConfigurationsFromCheckState(const TestTreeItem *item,
|
||||
}
|
||||
});
|
||||
|
||||
testConfig = new QtTestConfiguration();
|
||||
testConfig = new QtTestConfiguration(item->framework());
|
||||
testConfig->setTestCases(testCases);
|
||||
testConfig->setProjectFile(item->proFile());
|
||||
testConfig->setProject(ProjectExplorer::SessionManager::startupProject());
|
||||
@@ -342,7 +343,7 @@ TestTreeItem *QtTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new QtTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
return new QtTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
bool QtTestTreeItem::isGroupable() const
|
||||
|
@@ -33,7 +33,7 @@ namespace Internal {
|
||||
class QtTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QtTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(), const QString &filePath = QString(),
|
||||
Type type = Root);
|
||||
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
|
@@ -29,13 +29,14 @@
|
||||
#include "../qtest/qttestsettings.h"
|
||||
#include "../qtest/qttest_utils.h"
|
||||
#include "../autotestplugin.h"
|
||||
#include "../testframeworkmanager.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QuickTestConfiguration::QuickTestConfiguration()
|
||||
QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework)
|
||||
{
|
||||
setMixedDebugging(true);
|
||||
}
|
||||
@@ -43,10 +44,7 @@ QuickTestConfiguration::QuickTestConfiguration()
|
||||
TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(manager->settingsForTestFramework(id));
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(framework()->frameworkSettings());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput
|
||||
? QtTestOutputReader::XML
|
||||
: QtTestOutputReader::PlainText;
|
||||
@@ -56,9 +54,6 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface<Te
|
||||
|
||||
QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
static const Core::Id id
|
||||
= Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME);
|
||||
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
arguments.append(QTestUtils::filterInterfering
|
||||
@@ -66,8 +61,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
||||
omitted, true));
|
||||
}
|
||||
|
||||
TestFrameworkManager *manager = TestFrameworkManager::instance();
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(manager->settingsForTestFramework(id));
|
||||
auto qtSettings = dynamic_cast<QtTestSettings *>(framework()->frameworkSettings());
|
||||
if (!qtSettings)
|
||||
return arguments;
|
||||
if (qtSettings->useXMLOutput)
|
||||
|
@@ -33,7 +33,7 @@ namespace Internal {
|
||||
class QuickTestConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
QuickTestConfiguration();
|
||||
explicit QuickTestConfiguration(ITestFramework *framework);
|
||||
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
|
@@ -35,9 +35,9 @@ ITestParser *QuickTestFramework::createTestParser()
|
||||
return new QuickTestParser(this);
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestFramework::createRootNode() const
|
||||
TestTreeItem *QuickTestFramework::createRootNode()
|
||||
{
|
||||
return new QuickTestTreeItem(QCoreApplication::translate("QuickTestFramework", "Quick Test"),
|
||||
return new QuickTestTreeItem(this, QCoreApplication::translate("QuickTestFramework", "Quick Test"),
|
||||
QString(), TestTreeItem::Root);
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
protected:
|
||||
ITestParser *createTestParser() override;
|
||||
TestTreeItem *createRootNode() const override;
|
||||
TestTreeItem *createRootNode() override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -49,7 +49,7 @@ TestTreeItem *QuickTestParseResult::createTestTreeItem() const
|
||||
if (itemType == TestTreeItem::Root || itemType == TestTreeItem::TestDataTag)
|
||||
return nullptr;
|
||||
|
||||
QuickTestTreeItem *item = new QuickTestTreeItem(name, fileName, itemType);
|
||||
QuickTestTreeItem *item = new QuickTestTreeItem(framework, name, fileName, itemType);
|
||||
item->setProFile(proFile);
|
||||
item->setLine(line);
|
||||
item->setColumn(column);
|
||||
|
@@ -38,7 +38,7 @@ namespace Internal {
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::copyWithoutChildren()
|
||||
{
|
||||
QuickTestTreeItem *copied = new QuickTestTreeItem;
|
||||
QuickTestTreeItem *copied = new QuickTestTreeItem(framework());
|
||||
copied->copyBasicDataFrom(this);
|
||||
return copied;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
||||
if (child->type() == TestTreeItem::TestFunction)
|
||||
testFunctions << testName + "::" + child->name();
|
||||
});
|
||||
config = new QuickTestConfiguration;
|
||||
config = new QuickTestConfiguration(framework());
|
||||
config->setTestCases(testFunctions);
|
||||
config->setProjectFile(proFile());
|
||||
config->setProject(project);
|
||||
@@ -146,7 +146,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
||||
case TestFunction: {
|
||||
TestTreeItem *parent = parentItem();
|
||||
QStringList testFunction(parent->name() + "::" + name());
|
||||
config = new QuickTestConfiguration;
|
||||
config = new QuickTestConfiguration(framework());
|
||||
config->setTestCases(testFunction);
|
||||
config->setProjectFile(parent->proFile());
|
||||
config->setProject(project);
|
||||
@@ -186,7 +186,7 @@ static void testConfigurationFromCheckState(const TestTreeItem *item,
|
||||
oldFunctions << testFunctions;
|
||||
tc->setTestCases(oldFunctions);
|
||||
} else {
|
||||
tc = new QuickTestConfiguration;
|
||||
tc = new QuickTestConfiguration(item->framework());
|
||||
tc->setTestCases(testFunctions);
|
||||
tc->setProjectFile(item->proFile());
|
||||
tc->setProject(ProjectExplorer::SessionManager::startupProject());
|
||||
@@ -244,7 +244,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
|
||||
});
|
||||
// create TestConfiguration for each project file
|
||||
for (auto it = testsForProfile.begin(), end = testsForProfile.end(); it != end; ++it) {
|
||||
QuickTestConfiguration *tc = new QuickTestConfiguration;
|
||||
QuickTestConfiguration *tc = new QuickTestConfiguration(framework());
|
||||
tc->setTestCaseCount(it.value().testCount);
|
||||
tc->setProjectFile(it.key());
|
||||
tc->setProject(project);
|
||||
@@ -404,7 +404,7 @@ TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new QuickTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
return new QuickTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
bool QuickTestTreeItem::isGroupable() const
|
||||
|
@@ -33,8 +33,12 @@ namespace Internal {
|
||||
class QuickTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QuickTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
Type type = Root) : TestTreeItem(name, filePath, type) {}
|
||||
explicit QuickTestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(framework, name, filePath, type)
|
||||
{}
|
||||
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
QVariant data(int column, int role) const override;
|
||||
|
@@ -49,6 +49,11 @@ using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
TestConfiguration::TestConfiguration(ITestFramework *framework)
|
||||
: m_framework(framework)
|
||||
{
|
||||
}
|
||||
|
||||
TestConfiguration::~TestConfiguration()
|
||||
{
|
||||
m_testCases.clear();
|
||||
@@ -351,4 +356,9 @@ bool TestConfiguration::hasExecutable() const
|
||||
return !m_runnable.executable.isEmpty();
|
||||
}
|
||||
|
||||
ITestFramework *TestConfiguration::framework() const
|
||||
{
|
||||
return m_framework;
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
@@ -45,6 +45,7 @@ namespace Internal {
|
||||
class TestRunConfiguration;
|
||||
} // namespace Internal
|
||||
|
||||
class ITestFramework;
|
||||
class TestOutputReader;
|
||||
class TestResult;
|
||||
enum class TestRunMode;
|
||||
@@ -54,7 +55,7 @@ using TestResultPtr = QSharedPointer<TestResult>;
|
||||
class TestConfiguration
|
||||
{
|
||||
public:
|
||||
explicit TestConfiguration() = default;
|
||||
explicit TestConfiguration(ITestFramework *framework);
|
||||
virtual ~TestConfiguration();
|
||||
|
||||
void completeTestInformation(TestRunMode runMode);
|
||||
@@ -73,6 +74,7 @@ public:
|
||||
void setInternalTargets(const QSet<QString> &targets);
|
||||
void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
|
||||
|
||||
ITestFramework *framework() const;
|
||||
QStringList testCases() const { return m_testCases; }
|
||||
int testCaseCount() const { return m_testCaseCount; }
|
||||
QString executableFilePath() const;
|
||||
@@ -95,7 +97,9 @@ public:
|
||||
QProcess *app) const = 0;
|
||||
virtual QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const = 0;
|
||||
virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const = 0;
|
||||
|
||||
private:
|
||||
ITestFramework *m_framework;
|
||||
QStringList m_testCases;
|
||||
int m_testCaseCount = 0;
|
||||
QString m_projectFile;
|
||||
@@ -113,8 +117,8 @@ private:
|
||||
class DebuggableTestConfiguration : public TestConfiguration
|
||||
{
|
||||
public:
|
||||
explicit DebuggableTestConfiguration(TestRunMode runMode = TestRunMode::Run)
|
||||
: m_runMode(runMode) {}
|
||||
explicit DebuggableTestConfiguration(ITestFramework *framework, TestRunMode runMode = TestRunMode::Run)
|
||||
: TestConfiguration(framework), m_runMode(runMode) {}
|
||||
|
||||
void setRunMode(TestRunMode mode) { m_runMode = mode; }
|
||||
TestRunMode runMode() const { return m_runMode; }
|
||||
|
@@ -120,14 +120,6 @@ ITestFramework *TestFrameworkManager::frameworkForId(Id frameworkId)
|
||||
});
|
||||
}
|
||||
|
||||
IFrameworkSettings *TestFrameworkManager::settingsForTestFramework(
|
||||
const Id &frameworkId) const
|
||||
{
|
||||
ITestFramework *framework = frameworkForId(frameworkId);
|
||||
QTC_ASSERT(framework, return nullptr);
|
||||
return framework->frameworkSettings();
|
||||
}
|
||||
|
||||
void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
||||
{
|
||||
Internal::AutotestPlugin::settings()->fromSettings(s);
|
||||
|
@@ -61,7 +61,6 @@ public:
|
||||
TestFrameworks sortedRegisteredFrameworks() const;
|
||||
TestFrameworks sortedActiveFrameworks() const;
|
||||
|
||||
IFrameworkSettings *settingsForTestFramework(const Core::Id &frameworkId) const;
|
||||
void synchronizeSettings(QSettings *s);
|
||||
bool hasActiveFrameworks() const;
|
||||
|
||||
|
@@ -38,8 +38,10 @@
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type)
|
||||
: m_name(name),
|
||||
TestTreeItem::TestTreeItem(ITestFramework *framework, const QString &name,
|
||||
const QString &filePath, Type type)
|
||||
: m_framework(framework),
|
||||
m_name(name),
|
||||
m_filePath(filePath),
|
||||
m_type(type)
|
||||
{
|
||||
@@ -355,6 +357,11 @@ inline bool TestTreeItem::modifyName(const QString &name)
|
||||
return false;
|
||||
}
|
||||
|
||||
ITestFramework *TestTreeItem::framework() const
|
||||
{
|
||||
return m_framework;
|
||||
}
|
||||
|
||||
/*
|
||||
* try to find build system target that depends on the given file - if the file is no header
|
||||
* try to find the corresponding header and use this instead to find the respective target
|
||||
|
@@ -46,6 +46,7 @@ namespace Utils { class FilePath; }
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
class ITestFramework;
|
||||
class TestConfiguration;
|
||||
class TestParseResult;
|
||||
enum class TestRunMode;
|
||||
@@ -71,7 +72,9 @@ public:
|
||||
Naturally
|
||||
};
|
||||
|
||||
explicit TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||
explicit TestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
Type type = Root);
|
||||
|
||||
virtual TestTreeItem *copyWithoutChildren() = 0;
|
||||
@@ -83,6 +86,7 @@ public:
|
||||
bool modifyDataTagContent(const TestParseResult *result);
|
||||
bool modifyLineAndColumn(const TestParseResult *result);
|
||||
|
||||
ITestFramework *framework() const;
|
||||
const QString name() const { return m_name; }
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
const QString filePath() const { return m_filePath; }
|
||||
@@ -129,6 +133,7 @@ public:
|
||||
// decide whether an item should still be added to the treemodel
|
||||
virtual bool shouldBeAddedAfterFiltering() const { return true; }
|
||||
virtual QSet<QString> internalTargets() const;
|
||||
|
||||
protected:
|
||||
void copyBasicDataFrom(const TestTreeItem *other);
|
||||
typedef std::function<bool(const TestTreeItem *)> CompareFunction;
|
||||
@@ -146,6 +151,7 @@ private:
|
||||
Cleared
|
||||
};
|
||||
|
||||
ITestFramework *m_framework = nullptr;
|
||||
QString m_name;
|
||||
QString m_filePath;
|
||||
Qt::CheckState m_checked;
|
||||
|
Reference in New Issue
Block a user