Autotest: some FilePath::toFileInfo cleanup

Change-Id: I45395c5e83bc01d98d0bec20c992424d4150c844
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-06-09 09:23:24 +02:00
parent 09ead204ea
commit cb1b86645a
7 changed files with 20 additions and 21 deletions

View File

@@ -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<QString, int> 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<QString, int> foundNamesAndSets = m_model->boostTestSuitesAndTests();
QCOMPARE(expectedSuitesAndTests.size(), foundNamesAndSets.size());

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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() == "."){