forked from qt-creator/qt-creator
Autotest: Replace occurrences of FilePath::toString
Use more sensible alternatives instead of FilePath::toString Use FilePath capabilities instead of QDir/QFile. Change-Id: I47d3a2c4c5197074e6bcbeb20383a26d6cda120c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
committed by
andrii.semkiv
parent
f5dab0c7a5
commit
5edf4925af
@@ -102,7 +102,7 @@ bool CatchTestParser::processDocument(QPromise<TestParseResultPtr> &promise,
|
||||
if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot))
|
||||
return false;
|
||||
|
||||
const QString &filePath = doc->filePath().toString();
|
||||
const QString &filePath = doc->filePath().toUserOutput();
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
|
||||
if (!hasCatchNames(doc)) {
|
||||
|
@@ -36,9 +36,10 @@ static QString nonRootDisplayName(const CatchTreeItem *it)
|
||||
if (!project)
|
||||
return it->name();
|
||||
TestTreeItem *parent = it->parentItem();
|
||||
int baseDirSize = (parent->type() == TestTreeItem::GroupNode)
|
||||
? parent->filePath().toString().size() : project->projectDirectory().toString().size();
|
||||
return it->name().mid(baseDirSize + 1);
|
||||
const FilePath baseDir = (parent->type() == TestTreeItem::GroupNode)
|
||||
? parent->filePath()
|
||||
: project->projectDirectory();
|
||||
return it->filePath().relativePathFrom(baseDir).toUserOutput();
|
||||
}
|
||||
|
||||
QVariant CatchTreeItem::data(int column, int role) const
|
||||
|
@@ -109,7 +109,7 @@ QVariant GTestTreeItem::data(int column, int role) const
|
||||
case Qt::ToolTipRole:
|
||||
if (type() == GroupNode
|
||||
&& GTestFramework::staticGroupMode() == GTest::Constants::GTestFilter) {
|
||||
const auto tpl = QString("<p>%1</p><p>%2</p>").arg(filePath().toString());
|
||||
const auto tpl = QString("<p>%1</p><p>%2</p>").arg(filePath().path());
|
||||
return tpl.arg(Tr::tr("Change GTest filter in use inside the settings."));
|
||||
}
|
||||
break;
|
||||
@@ -535,9 +535,10 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
QTC_ASSERT(false, return false);
|
||||
}
|
||||
// FIXME gtest filter is no FilePath
|
||||
if (GTestFramework::currentGTestFilter() != filePath().toString()) // filter has changed in settings
|
||||
if (GTestFramework::currentGTestFilter()
|
||||
!= filePath().path()) // filter has changed in settings
|
||||
return false;
|
||||
bool matches = matchesFilter(filePath().toString(), fullName);
|
||||
bool matches = matchesFilter(filePath().path(), fullName);
|
||||
return (matches && name() == matchingString())
|
||||
|| (!matches && name() == notMatchingString());
|
||||
}
|
||||
|
@@ -157,7 +157,7 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons
|
||||
QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const FilePath &srcDir)
|
||||
{
|
||||
FilePaths dirs({srcDir});
|
||||
QStringList dirsStr({srcDir.toString()});
|
||||
QStringList dirsStr({srcDir.path()});
|
||||
ModelManagerInterface *qmlJsMM = QmlJSTools::Internal::ModelManager::instance();
|
||||
// make sure even files not listed in pro file are available inside the snapshot
|
||||
PathsAndLanguages paths;
|
||||
@@ -165,15 +165,15 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Fi
|
||||
ModelManagerInterface::importScan(ModelManagerInterface::workingCopy(), paths, qmlJsMM,
|
||||
false /*emitDocumentChanges*/, false /*onlyTheLib*/, true /*forceRescan*/ );
|
||||
|
||||
QDirIterator it(srcDir.toString(),
|
||||
QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
auto subDir = FilePath::fromFileInfo(it.fileInfo()).canonicalPath();
|
||||
dirs.append(subDir);
|
||||
dirsStr.append(subDir.toString());
|
||||
}
|
||||
srcDir.iterateDirectory(
|
||||
[&dirs, &dirsStr](const FilePath &p) {
|
||||
const FilePath &canonicalPath = p.canonicalPath();
|
||||
dirs.append(canonicalPath);
|
||||
dirsStr.append(canonicalPath.path());
|
||||
return IterationPolicy::Continue;
|
||||
},
|
||||
FileFilter{{}, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories});
|
||||
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this, dirsStr] { QuickTestParser::doUpdateWatchPaths(dirsStr); },
|
||||
|
@@ -377,7 +377,7 @@ QSet<QString> internalTargets(const FilePath &proFile)
|
||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
continue;
|
||||
if (projectPart->projectFile != proFile.toString())
|
||||
if (projectPart->projectFile != proFile.path())
|
||||
continue;
|
||||
if (Utils::anyOf(projectPart->projectMacros, [](const ProjectExplorer::Macro ¯o){
|
||||
return macro.type == ProjectExplorer::MacroType::Define &&
|
||||
|
@@ -86,7 +86,7 @@ static bool isLocal(Target *target)
|
||||
|
||||
static FilePath ensureExeEnding(const FilePath &file)
|
||||
{
|
||||
if (!HostOsInfo::isWindowsHost() || file.isEmpty() || file.toString().toLower().endsWith(".exe"))
|
||||
if (!HostOsInfo::isWindowsHost() || file.isEmpty() || file.suffix().toLower() == "exe")
|
||||
return file;
|
||||
return file.withExecutableSuffix();
|
||||
}
|
||||
@@ -122,9 +122,11 @@ void TestConfiguration::completeTestInformation(RunConfiguration *rc,
|
||||
FilePath buildBase;
|
||||
if (auto buildConfig = target->activeBuildConfiguration()) {
|
||||
buildBase = buildConfig->buildDirectory();
|
||||
const QString projBase = startupProject->projectDirectory().toString();
|
||||
if (m_projectFile.startsWith(projBase))
|
||||
m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath();
|
||||
const FilePath projBase = startupProject->projectDirectory();
|
||||
if (m_projectFile.isChildOf(projBase)) {
|
||||
m_buildDir
|
||||
= (buildBase.resolvePath(m_projectFile.relativePathFrom(projBase))).absolutePath();
|
||||
}
|
||||
}
|
||||
if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy)
|
||||
m_runConfig = new Internal::TestRunConfiguration(rc->target(), this);
|
||||
@@ -188,9 +190,11 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
|
||||
FilePath buildBase;
|
||||
if (auto buildConfig = target->activeBuildConfiguration()) {
|
||||
buildBase = buildConfig->buildDirectory();
|
||||
const QString projBase = startupProject->projectDirectory().toString();
|
||||
if (m_projectFile.startsWith(projBase))
|
||||
m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath();
|
||||
const FilePath projBase = startupProject->projectDirectory();
|
||||
if (m_projectFile.isChildOf(projBase)) {
|
||||
m_buildDir
|
||||
= (buildBase.resolvePath(m_projectFile.relativePathFrom(projBase))).absolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
// deployment information should get taken into account, but it pretty much seems as if
|
||||
|
@@ -527,8 +527,10 @@ void TestRunner::debugTests()
|
||||
|
||||
const FilePath &commandFilePath = config->executableFilePath();
|
||||
if (commandFilePath.isEmpty()) {
|
||||
reportResult(ResultType::MessageFatal, Tr::tr("Could not find command \"%1\". (%2)")
|
||||
.arg(config->executableFilePath().toString(), config->displayName()));
|
||||
reportResult(
|
||||
ResultType::MessageFatal,
|
||||
Tr::tr("Could not find command \"%1\". (%2)")
|
||||
.arg(config->executableFilePath().toUserOutput(), config->displayName()));
|
||||
onFinished();
|
||||
return;
|
||||
}
|
||||
@@ -573,7 +575,7 @@ void TestRunner::debugTests()
|
||||
if (useOutputProcessor) {
|
||||
TestOutputReader *outputreader = config->createOutputReader(nullptr);
|
||||
connect(outputreader, &TestOutputReader::newResult, this, &TestRunner::testResultReady);
|
||||
outputreader->setId(inferior.command.executable().toString());
|
||||
outputreader->setId(inferior.command.executable().toUserOutput());
|
||||
connect(outputreader, &TestOutputReader::newOutputLineAvailable,
|
||||
TestResultsPane::instance(), &TestResultsPane::addOutputLine);
|
||||
connect(runControl, &RunControl::appendMessage,
|
||||
@@ -786,9 +788,10 @@ void RunConfigurationSelectionDialog::populate()
|
||||
if (auto target = project->activeTarget()) {
|
||||
for (RunConfiguration *rc : target->runConfigurations()) {
|
||||
auto runnable = rc->runnable();
|
||||
const QStringList rcDetails = { runnable.command.executable().toString(),
|
||||
runnable.command.arguments(),
|
||||
runnable.workingDirectory.toString() };
|
||||
const QStringList rcDetails
|
||||
= {runnable.command.executable().toUserOutput(),
|
||||
runnable.command.arguments(),
|
||||
runnable.workingDirectory.toUserOutput()};
|
||||
m_rcCombo->addItem(rc->displayName(), rcDetails);
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ QVariant ITestTreeItem::data(int /*column*/, int role) const
|
||||
return Tr::tr("%1 (none)").arg(m_name);
|
||||
return m_name;
|
||||
case Qt::ToolTipRole:
|
||||
return m_filePath.toString();
|
||||
return m_filePath.toUserOutput();
|
||||
case Qt::DecorationRole:
|
||||
return testTreeIcon(m_type);
|
||||
case Qt::CheckStateRole:
|
||||
@@ -113,14 +113,13 @@ bool ITestTreeItem::lessThan(const ITestTreeItem *other, ITestTreeItem::SortMode
|
||||
return lhs.compare(rhs, Qt::CaseInsensitive) > 0;
|
||||
case Naturally: {
|
||||
if (type() == GroupNode && other->type() == GroupNode) {
|
||||
return filePath().toString().compare(other->filePath().toString(),
|
||||
Qt::CaseInsensitive) > 0;
|
||||
return filePath().path().compare(other->filePath().path(), Qt::CaseInsensitive) > 0;
|
||||
}
|
||||
|
||||
const Link &leftLink = data(0, LinkRole).value<Link>();
|
||||
const Link &rightLink = other->data(0, LinkRole).value<Link>();
|
||||
const int comparison = leftLink.targetFilePath.toString().compare(
|
||||
rightLink.targetFilePath.toString(), Qt::CaseInsensitive);
|
||||
const int comparison = leftLink.targetFilePath.path()
|
||||
.compare(rightLink.targetFilePath.path(), Qt::CaseInsensitive);
|
||||
if (comparison == 0) {
|
||||
return leftLink.targetLine == rightLink.targetLine
|
||||
? leftLink.targetColumn > rightLink.targetColumn
|
||||
|
@@ -80,7 +80,7 @@ public:
|
||||
ITestBase *testBase() const { return m_testBase; }
|
||||
|
||||
virtual bool lessThan(const ITestTreeItem *other, SortMode mode) const;
|
||||
QString cacheName() const { return m_filePath.toString() + ':' + m_name; }
|
||||
QString cacheName() const { return m_filePath.path() + ':' + m_name; }
|
||||
|
||||
protected:
|
||||
void setType(Type type) { m_type = type; }
|
||||
|
Reference in New Issue
Block a user