From cb1b86645aa06e3415fdd25067f1aba43e285935 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 9 Jun 2021 09:23:24 +0200 Subject: [PATCH] Autotest: some FilePath::toFileInfo cleanup Change-Id: I45395c5e83bc01d98d0bec20c992424d4150c844 Reviewed-by: Christian Stenger --- src/plugins/autotest/autotestunittests.cpp | 19 ++++++++++--------- .../autotest/boost/boosttesttreeitem.cpp | 4 ++-- src/plugins/autotest/catch/catchtreeitem.cpp | 4 ++-- src/plugins/autotest/gtest/gtesttreeitem.cpp | 5 ++--- src/plugins/autotest/qtest/qttesttreeitem.cpp | 4 ++-- .../autotest/quick/quicktesttreeitem.cpp | 4 ++-- src/plugins/autotest/testconfiguration.cpp | 1 - 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index e395e71379c..6a6a9c10063 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -268,21 +268,22 @@ void AutoTestUnitTests::testCodeParserBoostTest() QCOMPARE(m_model->boostTestNamesCount(), 5); - QString basePath; - if (auto project = projectInfo.project()) - basePath = project->projectFilePath().toFileInfo().absolutePath(); + + auto project = projectInfo.project(); + QVERIFY(project); + const Utils::FilePath basePath = project->projectFilePath().absolutePath(); QVERIFY(!basePath.isEmpty()); QMap expectedSuitesAndTests; auto pathConstructor = [basePath, extension](const QString &name, const QString &subPath) { - return QString(name + '|' + basePath + subPath + extension); + return QString(name + '|' + basePath.pathAppended(subPath + extension).toString()); }; - expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "/tests/deco/deco"), 2); // decorators w/o suite - expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "/tests/fix/fix"), 2); // fixtures - expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "/tests/params/params"), 3); // functions - expectedSuitesAndTests.insert(pathConstructor("Suite1", "/tests/deco/deco"), 4); - expectedSuitesAndTests.insert(pathConstructor("SuiteOuter", "/tests/deco/deco"), 5); // 2 sub suites + 3 tests + expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "tests/deco/deco"), 2); // decorators w/o suite + expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "tests/fix/fix"), 2); // fixtures + expectedSuitesAndTests.insert(pathConstructor("Master Test Suite", "tests/params/params"), 3); // functions + expectedSuitesAndTests.insert(pathConstructor("Suite1", "tests/deco/deco"), 4); + expectedSuitesAndTests.insert(pathConstructor("SuiteOuter", "tests/deco/deco"), 5); // 2 sub suites + 3 tests QMap foundNamesAndSets = m_model->boostTestSuitesAndTests(); QCOMPARE(expectedSuitesAndTests.size(), foundNamesAndSets.size()); diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index 74e97409738..8aeb35a7eea 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -144,8 +144,8 @@ bool BoostTestTreeItem::modify(const TestParseResult *result) TestTreeItem *BoostTestTreeItem::createParentGroupNode() const { - const QFileInfo base = filePath().absolutePath().toFileInfo(); - return new BoostTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); + const Utils::FilePath &absPath = filePath().absolutePath(); + return new BoostTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } QString BoostTestTreeItem::prependWithParentsSuitePaths(const QString &testName) const diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp index 96ee8816537..020c5fd7d16 100644 --- a/src/plugins/autotest/catch/catchtreeitem.cpp +++ b/src/plugins/autotest/catch/catchtreeitem.cpp @@ -139,8 +139,8 @@ bool CatchTreeItem::modify(const TestParseResult *result) TestTreeItem *CatchTreeItem::createParentGroupNode() const { - const QFileInfo base(filePath().toFileInfo().absolutePath()); - return new CatchTreeItem(framework(), base.baseName(), filePath(), TestTreeItem::GroupNode); + const Utils::FilePath absPath = filePath().absolutePath(); + return new CatchTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } bool CatchTreeItem::canProvideTestConfiguration() const diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 2d2012e35d3..a52b8b63e54 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -464,9 +464,8 @@ bool GTestTreeItem::modify(const TestParseResult *result) TestTreeItem *GTestTreeItem::createParentGroupNode() const { if (GTestFramework::groupMode() == GTest::Constants::Directory) { - const QFileInfo base = filePath().absolutePath().toFileInfo(); - return new GTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), - TestTreeItem::GroupNode); + const Utils::FilePath &absPath = filePath().absolutePath(); + return new GTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } else { // GTestFilter QTC_ASSERT(childCount(), return nullptr); // paranoia const TestTreeItem *firstChild = childItem(0); diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index ebce3d82f92..6655bec5095 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -408,8 +408,8 @@ bool QtTestTreeItem::modify(const TestParseResult *result) TestTreeItem *QtTestTreeItem::createParentGroupNode() const { - const QFileInfo base = filePath().absolutePath().toFileInfo(); - return new QtTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); + const Utils::FilePath &absPath = filePath().absolutePath(); + return new QtTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } bool QtTestTreeItem::isGroupable() const diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index ad42099720d..1be0e7153b9 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -375,8 +375,8 @@ bool QuickTestTreeItem::removeOnSweepIfEmpty() const TestTreeItem *QuickTestTreeItem::createParentGroupNode() const { - const QFileInfo base = filePath().absolutePath().toFileInfo(); - return new QuickTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); + const Utils::FilePath &absPath = filePath().absolutePath(); + return new QuickTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } bool QuickTestTreeItem::isGroupable() const diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index e15fe3ac570..1772e54fbfb 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -84,7 +84,6 @@ Utils::FilePath ITestConfiguration::executableFilePath() const if (!hasExecutable()) return {}; - QFileInfo commandFileInfo = m_runnable.executable.toFileInfo(); if (m_runnable.executable.isExecutableFile() && m_runnable.executable.path() != ".") { return m_runnable.executable.absoluteFilePath(); } else if (m_runnable.executable.path() == "."){