AutoTest: Use new approach for settings

Avoids a couple of unneeded casts.

Change-Id: Ib3361d4ad2c69e4f0e4a44c5e9b3f385cefb6084
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2023-07-13 10:06:14 +02:00
parent af998dae2c
commit fa815edae3
8 changed files with 11 additions and 18 deletions

View File

@@ -77,10 +77,7 @@ void AutoTestUnitTests::initTestCase()
} }
// Enable quick check for derived tests // Enable quick check for derived tests
static const Id id = Id("AutoTest.Framework.QtTest"); theQtTestFramework().quickCheckForDerivedTests.setValue(true);
static_cast<Autotest::Internal::QtTestFramework *>(
TestFrameworkManager::frameworkForId(id))
->quickCheckForDerivedTests.setValue(true);
} }
void AutoTestUnitTests::cleanupTestCase() void AutoTestUnitTests::cleanupTestCase()

View File

@@ -17,7 +17,7 @@ namespace Internal {
TestOutputReader *BoostTestConfiguration::createOutputReader(Process *app) const TestOutputReader *BoostTestConfiguration::createOutputReader(Process *app) const
{ {
BoostTestFramework &settings = *static_cast<BoostTestFramework *>(framework()); BoostTestFramework &settings = theBoostTestFramework();
return new BoostTestOutputReader(app, buildDirectory(), projectFile(), return new BoostTestOutputReader(app, buildDirectory(), projectFile(),
LogLevel(settings.logLevel()), LogLevel(settings.logLevel()),
ReportLevel(settings.reportLevel())); ReportLevel(settings.reportLevel()));
@@ -85,7 +85,7 @@ static QStringList filterInterfering(const QStringList &provided, QStringList *o
QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
{ {
BoostTestFramework &boostSettings = *static_cast<BoostTestFramework *>(framework()); BoostTestFramework &boostSettings = theBoostTestFramework();
QStringList arguments; QStringList arguments;
arguments << "-l" << BoostTestFramework::logLevelToOption(LogLevel(boostSettings.logLevel())); arguments << "-l" << BoostTestFramework::logLevelToOption(LogLevel(boostSettings.logLevel()));
arguments << "-r" << BoostTestFramework::reportLevelToOption(ReportLevel(boostSettings.reportLevel())); arguments << "-r" << BoostTestFramework::reportLevelToOption(ReportLevel(boostSettings.reportLevel()));

View File

@@ -83,7 +83,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
' ', Qt::SkipEmptyParts), omitted); ' ', Qt::SkipEmptyParts), omitted);
} }
CatchFramework &settings = *static_cast<CatchFramework *>(framework()); CatchFramework &settings = theCatchFramework();
if (settings.abortAfterChecked()) if (settings.abortAfterChecked())
arguments << "-x" << QString::number(settings.abortAfter()); arguments << "-x" << QString::number(settings.abortAfter());

View File

@@ -88,8 +88,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi
const ProjectExplorer::BuildSystem *buildSystem = target->buildSystem(); const ProjectExplorer::BuildSystem *buildSystem = target->buildSystem();
QStringList options{"--timeout", QString::number(testSettings().timeout() / 1000)}; QStringList options{"--timeout", QString::number(testSettings().timeout() / 1000)};
auto ctestSettings = static_cast<CTestTool *>(testBase()); options << theCTestTool().activeSettingsAsOptions();
options << ctestSettings->activeSettingsAsOptions();
CommandLine command = buildSystem->commandLineForTests(selected, options); CommandLine command = buildSystem->commandLineForTests(selected, options);
if (command.executable().isEmpty()) if (command.executable().isEmpty())
return {}; return {};

View File

@@ -66,7 +66,7 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
arguments << "--gtest_filter=\"" + testSets.join(':') + '"'; arguments << "--gtest_filter=\"" + testSets.join(':') + '"';
} }
GTestFramework &gSettings = *static_cast<GTestFramework *>(framework()); GTestFramework &gSettings = theGTestFramework();
if (gSettings.runDisabled()) if (gSettings.runDisabled())
arguments << "--gtest_also_run_disabled_tests"; arguments << "--gtest_also_run_disabled_tests";

View File

@@ -28,8 +28,7 @@ static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode)
TestOutputReader *QtTestConfiguration::createOutputReader(Process *app) const TestOutputReader *QtTestConfiguration::createOutputReader(Process *app) const
{ {
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework()); const QtTestOutputReader::OutputMode mode = theQtTestFramework().useXMLOutput()
const QtTestOutputReader::OutputMode mode = qtSettings.useXMLOutput()
? QtTestOutputReader::XML ? QtTestOutputReader::XML
: QtTestOutputReader::PlainText; : QtTestOutputReader::PlainText;
return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QtTest); return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QtTest);
@@ -43,7 +42,7 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
runnable().command.arguments().split(' ', Qt::SkipEmptyParts), runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
omitted, false)); omitted, false));
} }
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework()); QtTestFramework &qtSettings = theQtTestFramework();
if (qtSettings.useXMLOutput()) if (qtSettings.useXMLOutput())
arguments << "-xml"; arguments << "-xml";
if (!testCases().isEmpty()) if (!testCases().isEmpty())

View File

@@ -21,8 +21,7 @@ QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework)
TestOutputReader *QuickTestConfiguration::createOutputReader(Process *app) const TestOutputReader *QuickTestConfiguration::createOutputReader(Process *app) const
{ {
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework()); const QtTestOutputReader::OutputMode mode = theQtTestFramework().useXMLOutput()
const QtTestOutputReader::OutputMode mode = qtSettings.useXMLOutput()
? QtTestOutputReader::XML ? QtTestOutputReader::XML
: QtTestOutputReader::PlainText; : QtTestOutputReader::PlainText;
return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QuickTest); return new QtTestOutputReader(app, buildDirectory(), projectFile(), mode, TestType::QuickTest);
@@ -37,7 +36,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
omitted, true)); omitted, true));
} }
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework()); QtTestFramework &qtSettings = theQtTestFramework();
if (qtSettings.useXMLOutput()) if (qtSettings.useXMLOutput())
arguments << "-xml"; arguments << "-xml";
if (!testCases().isEmpty()) if (!testCases().isEmpty())

View File

@@ -357,8 +357,7 @@ void QuickTestParser::init(const QSet<FilePath> &filesToParse, bool fullParse)
m_mainCppFiles.clear(); m_mainCppFiles.clear();
} }
QtTestFramework &qtSettings = *static_cast<QtTestFramework *>(framework()); m_checkForDerivedTests = theQtTestFramework().quickCheckForDerivedTests();
m_checkForDerivedTests = qtSettings.quickCheckForDerivedTests();
CppParser::init(filesToParse, fullParse); CppParser::init(filesToParse, fullParse);
} }