forked from qt-creator/qt-creator
AutoTest: Use Utils::FilePath for files and directories
Still some missing bits as some QString members had different meanings depending on their context. Change-Id: Ib48eab54498974a26bbd5123cbffeefee5f7e79c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -375,7 +375,7 @@ void AutotestPluginPrivate::onRunUnderCursorTriggered(TestRunMode mode)
|
||||
|
||||
// check whether we have been triggered on a test function definition
|
||||
const int line = currentEditor->currentLine();
|
||||
const QString &filePath = currentEditor->textDocument()->filePath().toString();
|
||||
const Utils::FilePath &filePath = currentEditor->textDocument()->filePath();
|
||||
const QList<ITestTreeItem *> filteredItems = Utils::filtered(testsItems, [&](ITestTreeItem *it){
|
||||
return it->line() == line && it->filePath() == filePath;
|
||||
});
|
||||
|
@@ -43,7 +43,7 @@ ITestTreeItem *BoostTestFramework::createRootNode()
|
||||
this,
|
||||
QCoreApplication::translate("BoostTestFramework",
|
||||
BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *BoostTestFramework::name() const
|
||||
|
@@ -40,15 +40,10 @@ namespace Internal {
|
||||
|
||||
static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg)
|
||||
|
||||
static QString constructSourceFilePath(const QString &path, const QString &filePath)
|
||||
{
|
||||
return QFileInfo(path, filePath).canonicalFilePath();
|
||||
}
|
||||
|
||||
BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication,
|
||||
const QString &buildDirectory,
|
||||
const QString &projectFile,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile,
|
||||
LogLevel log, ReportLevel report)
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
, m_projectFile(projectFile)
|
||||
|
@@ -39,8 +39,8 @@ class BoostTestOutputReader : public TestOutputReader
|
||||
Q_OBJECT
|
||||
public:
|
||||
BoostTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile, LogLevel log, ReportLevel report);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile, LogLevel log, ReportLevel report);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
void processStdError(const QByteArray &outputLine) override;
|
||||
@@ -51,12 +51,12 @@ private:
|
||||
void sendCompleteInformation();
|
||||
void handleMessageMatch(const QRegularExpressionMatch &match);
|
||||
void reportNoOutputFinish(const QString &description, ResultType type);
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_currentModule;
|
||||
QString m_currentSuite;
|
||||
QString m_currentTest;
|
||||
QString m_description;
|
||||
QString m_fileName;
|
||||
Utils::FilePath m_fileName;
|
||||
ResultType m_result = ResultType::Invalid;
|
||||
int m_lineNumber = 0;
|
||||
int m_testCaseCount = -1;
|
||||
|
@@ -98,8 +98,9 @@ static bool hasBoostTestMacros(const CPlusPlus::Document::Ptr &doc)
|
||||
return false;
|
||||
}
|
||||
|
||||
static BoostTestParseResult *createParseResult(const QString &name, const QString &filePath,
|
||||
const QString &projectFile, ITestFramework *framework,
|
||||
static BoostTestParseResult *createParseResult(const QString &name, const Utils::FilePath &filePath,
|
||||
const Utils::FilePath &projectFile,
|
||||
ITestFramework *framework,
|
||||
TestTreeItem::Type type, const BoostTestInfo &info)
|
||||
{
|
||||
BoostTestParseResult *partialSuite = new BoostTestParseResult(framework);
|
||||
@@ -116,21 +117,19 @@ static BoostTestParseResult *createParseResult(const QString &name, const QStrin
|
||||
}
|
||||
|
||||
bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc))
|
||||
return false;
|
||||
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QString &filePath = doc->fileName();
|
||||
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
||||
const auto projectFile = projectPart->projectFile;
|
||||
const QByteArray &fileContent = getFileContent(filePath);
|
||||
const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
|
||||
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
||||
const BoostTestCodeLocationList foundTests = codeParser.findTests();
|
||||
@@ -141,7 +140,7 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
BoostTestInfoList suitesStates = locationAndType.m_suitesState;
|
||||
BoostTestInfo firstSuite = suitesStates.first();
|
||||
QStringList suites = firstSuite.fullName.split('/');
|
||||
BoostTestParseResult *topLevelSuite = createParseResult(suites.first(), filePath,
|
||||
BoostTestParseResult *topLevelSuite = createParseResult(suites.first(), fileName,
|
||||
projectFile, framework(),
|
||||
TestTreeItem::TestSuite,
|
||||
firstSuite);
|
||||
@@ -150,7 +149,7 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
while (!suitesStates.isEmpty()) {
|
||||
firstSuite = suitesStates.first();
|
||||
suites = firstSuite.fullName.split('/');
|
||||
BoostTestParseResult *suiteResult = createParseResult(suites.last(), filePath,
|
||||
BoostTestParseResult *suiteResult = createParseResult(suites.last(), fileName,
|
||||
projectFile, framework(),
|
||||
TestTreeItem::TestSuite,
|
||||
firstSuite);
|
||||
@@ -163,7 +162,7 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
BoostTestInfo tmpInfo{
|
||||
locationAndType.m_suitesState.last().fullName + "::" + locationAndType.m_name,
|
||||
locationAndType.m_state, locationAndType.m_line};
|
||||
BoostTestParseResult *funcResult = createParseResult(locationAndType.m_name, filePath,
|
||||
BoostTestParseResult *funcResult = createParseResult(locationAndType.m_name, fileName,
|
||||
projectFile, framework(),
|
||||
locationAndType.m_type,
|
||||
tmpInfo);
|
||||
|
@@ -45,7 +45,7 @@ class BoostTestParser : public CppParser
|
||||
public:
|
||||
explicit BoostTestParser(ITestFramework *framework) : CppParser(framework) {}
|
||||
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) override;
|
||||
const Utils::FilePath &fileName) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,7 +36,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
BoostTestResult::BoostTestResult(const QString &id, const QString &projectFile, const QString &name)
|
||||
BoostTestResult::BoostTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name)
|
||||
: TestResult(id, name), m_projectFile(projectFile)
|
||||
{
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ class BoostTestTreeItem;
|
||||
class BoostTestResult : public TestResult
|
||||
{
|
||||
public:
|
||||
BoostTestResult(const QString &id, const QString &projectFile, const QString &name);
|
||||
BoostTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name);
|
||||
const QString outputString(bool selected) const override;
|
||||
|
||||
bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const override;
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
bool matches(const BoostTestTreeItem *item) const;
|
||||
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_testSuite;
|
||||
QString m_testCase;
|
||||
};
|
||||
|
@@ -77,11 +77,9 @@ TestTreeItem *BoostTestTreeItem::find(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (result->framework->grouping()) {
|
||||
const QFileInfo fileInfo(bResult->fileName);
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
BoostTestTreeItem *group = static_cast<BoostTestTreeItem *>(childAt(row));
|
||||
if (group->filePath() != base.absoluteFilePath())
|
||||
if (group->filePath() != bResult->fileName.absoluteFilePath())
|
||||
continue;
|
||||
if (auto groupChild = group->findChildByNameStateAndFile(
|
||||
bResult->name, bResult->state, bResult->proFile)) {
|
||||
@@ -146,9 +144,8 @@ bool BoostTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
TestTreeItem *BoostTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new BoostTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
const QFileInfo base = filePath().absolutePath().toFileInfo();
|
||||
return new BoostTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
QString BoostTestTreeItem::prependWithParentsSuitePaths(const QString &testName) const
|
||||
@@ -188,7 +185,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const
|
||||
};
|
||||
|
||||
// we only need the unique project files (and number of test cases for the progress indicator)
|
||||
QHash<QString, BoostTestCases> testsPerProjectfile;
|
||||
QHash<Utils::FilePath, BoostTestCases> testsPerProjectfile;
|
||||
forAllChildItems([&testsPerProjectfile](TestTreeItem *item){
|
||||
if (item->type() != TestSuite)
|
||||
return;
|
||||
@@ -231,7 +228,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getTestConfigurations(
|
||||
QSet<QString> internalTargets;
|
||||
};
|
||||
|
||||
QHash<QString, BoostTestCases> testCasesForProjectFile;
|
||||
QHash<Utils::FilePath, BoostTestCases> testCasesForProjectFile;
|
||||
forAllChildren([&testCasesForProjectFile, &predicate](TreeItem *it){
|
||||
auto item = static_cast<BoostTestTreeItem *>(it);
|
||||
if (item->type() != TestCase)
|
||||
@@ -371,7 +368,7 @@ bool BoostTestTreeItem::enabled() const
|
||||
|
||||
TestTreeItem *BoostTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
||||
BoostTestTreeItem::TestStates state,
|
||||
const QString &proFile) const
|
||||
const Utils::FilePath &proFile) const
|
||||
{
|
||||
return static_cast<TestTreeItem *>(
|
||||
findAnyChild([name, state, proFile](const Utils::TreeItem *other){
|
||||
|
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
explicit BoostTestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(framework, name, filePath, type)
|
||||
{}
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
bool enabled() const;
|
||||
TestTreeItem *findChildByNameStateAndFile(const QString &name,
|
||||
BoostTestTreeItem::TestStates state,
|
||||
const QString &proFile) const;
|
||||
const Utils::FilePath &proFile) const;
|
||||
QString prependWithParentsSuitePaths(const QString &testName) const;
|
||||
QList<ITestConfiguration *> getTestConfigurations(
|
||||
std::function<bool(BoostTestTreeItem *)> predicate) const;
|
||||
|
@@ -49,7 +49,7 @@ ITestTreeItem *CatchFramework::createRootNode()
|
||||
{
|
||||
return new CatchTreeItem(this,
|
||||
QCoreApplication::translate("CatchFramework", "Catch Test"),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -49,8 +49,8 @@ namespace CatchXml {
|
||||
}
|
||||
|
||||
CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile)
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile)
|
||||
: TestOutputReader (futureInterface, testApplication, buildDirectory)
|
||||
, m_projectFile(projectFile)
|
||||
{
|
||||
@@ -174,11 +174,8 @@ TestResultPtr CatchOutputReader::createDefaultResult() const
|
||||
result->setDescription(m_testCaseInfo.last().name);
|
||||
result->setLine(m_testCaseInfo.last().line);
|
||||
const QString givenPath = m_testCaseInfo.last().filename;
|
||||
const Utils::FilePath filePath = Utils::FilePath::fromFileInfo(QFileInfo(givenPath));
|
||||
if (!givenPath.isEmpty()) {
|
||||
result->setFileName(QDir::isAbsolutePath(givenPath)
|
||||
? filePath.toString()
|
||||
: QFileInfo(m_buildDir + '/' + givenPath).canonicalFilePath());
|
||||
result->setFileName(constructSourceFilePath(m_buildDir, givenPath));
|
||||
}
|
||||
} else {
|
||||
result = new CatchResult(id(), QString());
|
||||
|
@@ -39,8 +39,8 @@ class CatchOutputReader : public TestOutputReader
|
||||
|
||||
public:
|
||||
CatchOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile);
|
||||
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLineWithNewLine) override;
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
QStack<TestOutputNode> m_testCaseInfo;
|
||||
int m_sectionDepth = 0;
|
||||
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_currentTagName;
|
||||
QString m_currentExpression;
|
||||
QXmlStreamReader m_xmlReader;
|
||||
|
@@ -73,7 +73,7 @@ const ITestTreeItem *CatchResult::findTestTreeItem() const
|
||||
return nullptr;
|
||||
|
||||
const QString tcName = name();
|
||||
const QString tcFilePath = fileName();
|
||||
const Utils::FilePath tcFilePath = fileName();
|
||||
return rootNode->findAnyChild([&tcName, &tcFilePath](const Utils::TreeItem *item) {
|
||||
const auto treeItem = static_cast<const CatchTreeItem *>(item);
|
||||
if (!treeItem || treeItem->filePath() != tcFilePath)
|
||||
|
@@ -105,7 +105,8 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface, const QString &fileName)
|
||||
bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot) || !hasCatchNames(doc))
|
||||
@@ -113,28 +114,28 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QString &filePath = doc->fileName();
|
||||
const QByteArray &fileContent = getFileContent(filePath);
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
QString proFile;
|
||||
Utils::FilePath proFile;
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
||||
proFile = projectPart->projectFile;
|
||||
proFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||
|
||||
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
||||
const CatchTestCodeLocationList foundTests = codeParser.findTests();
|
||||
|
||||
CatchParseResult *parseResult = new CatchParseResult(framework());
|
||||
parseResult->itemType = TestTreeItem::TestSuite;
|
||||
parseResult->fileName = filePath;
|
||||
parseResult->fileName = fileName;
|
||||
parseResult->name = filePath;
|
||||
parseResult->displayName = filePath;
|
||||
parseResult->proFile = projectParts.first()->projectFile;
|
||||
parseResult->proFile = proFile;
|
||||
|
||||
for (const CatchTestCodeLocationAndType & testLocation : foundTests) {
|
||||
CatchParseResult *testCase = new CatchParseResult(framework());
|
||||
testCase->fileName = filePath;
|
||||
testCase->fileName = fileName;
|
||||
testCase->name = testLocation.m_name;
|
||||
testCase->proFile = proFile;
|
||||
testCase->itemType = testLocation.m_type;
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
CatchTestParser(ITestFramework *framework)
|
||||
: CppParser(framework) {}
|
||||
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) override;
|
||||
const Utils::FilePath &fileName) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -49,7 +49,7 @@ static QString nonRootDisplayName(const CatchTreeItem *it)
|
||||
return it->name();
|
||||
TestTreeItem *parent = it->parentItem();
|
||||
int baseDirSize = (parent->type() == TestTreeItem::GroupNode)
|
||||
? parent->filePath().size() : project->projectDirectory().toString().size();
|
||||
? parent->filePath().toString().size() : project->projectDirectory().toString().size();
|
||||
return it->name().mid(baseDirSize + 1);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (result->framework->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
const Utils::FilePath path = result->fileName.absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
TestTreeItem *group = childItem(row);
|
||||
if (group->filePath() != path)
|
||||
@@ -139,9 +139,8 @@ bool CatchTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
TestTreeItem *CatchTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new CatchTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
const QFileInfo base(filePath().toFileInfo().absolutePath());
|
||||
return new CatchTreeItem(framework(), base.baseName(), filePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
bool CatchTreeItem::canProvideTestConfiguration() const
|
||||
@@ -189,7 +188,7 @@ struct CatchTestCases
|
||||
};
|
||||
|
||||
static void collectTestInfo(const TestTreeItem *item,
|
||||
QHash<QString, CatchTestCases> &testCasesForProfile,
|
||||
QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile,
|
||||
bool ignoreCheckState)
|
||||
{
|
||||
QTC_ASSERT(item, return);
|
||||
@@ -206,7 +205,7 @@ static void collectTestInfo(const TestTreeItem *item,
|
||||
QTC_ASSERT(childCount != 0, return);
|
||||
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
||||
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
||||
const QString &projectFile = item->childItem(0)->proFile();
|
||||
const Utils::FilePath &projectFile = item->childItem(0)->proFile();
|
||||
item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) {
|
||||
CatchTreeItem *current = static_cast<CatchTreeItem *>(it);
|
||||
testCasesForProfile[projectFile].names.append(current->testCasesString());
|
||||
@@ -227,7 +226,7 @@ static void collectTestInfo(const TestTreeItem *item,
|
||||
}
|
||||
|
||||
static void collectFailedTestInfo(const CatchTreeItem *item,
|
||||
QHash<QString, CatchTestCases> &testCasesForProfile)
|
||||
QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile)
|
||||
{
|
||||
QTC_ASSERT(item, return);
|
||||
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
||||
@@ -263,7 +262,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, CatchTestCases> testCasesForProFile;
|
||||
QHash<Utils::FilePath, CatchTestCases> testCasesForProFile;
|
||||
collectFailedTestInfo(this, testCasesForProFile);
|
||||
|
||||
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
||||
@@ -334,7 +333,7 @@ QList<ITestConfiguration *> CatchTreeItem::getTestConfigurations(bool ignoreChec
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, CatchTestCases> testCasesForProfile;
|
||||
QHash<Utils::FilePath, CatchTestCases> testCasesForProfile;
|
||||
for (int row = 0, end = childCount(); row < end; ++row)
|
||||
collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState);
|
||||
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit CatchTreeItem(ITestFramework *testFramework, const QString &name = QString(),
|
||||
const QString &filePath = QString(), Type type = Root)
|
||||
const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type) {}
|
||||
|
||||
void setStates(CatchTreeItem::TestStates state) { m_state = state; }
|
||||
|
@@ -71,7 +71,8 @@ private:
|
||||
};
|
||||
|
||||
CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory)
|
||||
QProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory)
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
{
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class CTestOutputReader final : public Autotest::TestOutputReader
|
||||
Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::CTestOutputReader)
|
||||
public:
|
||||
CTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory);
|
||||
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLineWithNewLine) final;
|
||||
|
@@ -40,8 +40,7 @@ Utils::Id CTestTool::buildSystemId() const
|
||||
|
||||
ITestTreeItem *CTestTool::createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci)
|
||||
{
|
||||
CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path.toString(),
|
||||
TestTreeItem::TestCase);
|
||||
CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path, TestTreeItem::TestCase);
|
||||
item->setLine(tci.line);
|
||||
return item;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ ITestTreeItem *CTestTool::createRootNode()
|
||||
{
|
||||
return new CTestTreeItem(this,
|
||||
QCoreApplication::translate("CTestTool", "CTest"),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -43,7 +43,7 @@ namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
CTestTreeItem::CTestTreeItem(ITestBase *testBase, const QString &name,
|
||||
const QString &filepath, Type type)
|
||||
const Utils::FilePath &filepath, Type type)
|
||||
: ITestTreeItem(testBase, name, filepath, type)
|
||||
{
|
||||
}
|
||||
@@ -88,7 +88,7 @@ QVariant CTestTreeItem::data(int column, int role) const
|
||||
return checked();
|
||||
if (role == LinkRole) {
|
||||
QVariant itemLink;
|
||||
itemLink.setValue(Utils::Link(Utils::FilePath::fromString(filePath()), line()));
|
||||
itemLink.setValue(Utils::Link(filePath(), line()));
|
||||
return itemLink;
|
||||
}
|
||||
return ITestTreeItem::data(column, role);
|
||||
|
@@ -33,7 +33,7 @@ namespace Internal {
|
||||
class CTestTreeItem final : public Autotest::ITestTreeItem
|
||||
{
|
||||
public:
|
||||
CTestTreeItem(ITestBase *testBase, const QString &name, const QString &filepath, Type type);
|
||||
CTestTreeItem(ITestBase *testBase, const QString &name, const Utils::FilePath &filepath, Type type);
|
||||
|
||||
QList<ITestConfiguration *> getAllTestConfigurations() const final;
|
||||
QList<ITestConfiguration *> getSelectedTestConfigurations() const final;
|
||||
|
@@ -50,7 +50,7 @@ ITestTreeItem *GTestFramework::createRootNode()
|
||||
this,
|
||||
QCoreApplication::translate("GTestFramework",
|
||||
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
|
@@ -36,14 +36,10 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
static QString constructSourceFilePath(const QString &path, const QString &filePath)
|
||||
{
|
||||
return QFileInfo(path, filePath).canonicalFilePath();
|
||||
}
|
||||
|
||||
GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile)
|
||||
QProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile)
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
, m_projectFile(projectFile)
|
||||
{
|
||||
@@ -181,7 +177,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(type);
|
||||
testResult->setLine(match.captured(3).toInt());
|
||||
const QString file = constructSourceFilePath(m_buildDir, match.captured(2));
|
||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2));
|
||||
if (!file.isEmpty())
|
||||
testResult->setFileName(file);
|
||||
testResult->setDescription(match.captured(4));
|
||||
@@ -246,7 +242,7 @@ void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResul
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageLocation);
|
||||
testResult->setLine(innerMatch.captured(2).toInt());
|
||||
QString file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
||||
if (!file.isEmpty())
|
||||
testResult->setFileName(file);
|
||||
resultDescription << output;
|
||||
|
@@ -38,8 +38,8 @@ class GTestOutputReader : public TestOutputReader
|
||||
|
||||
public:
|
||||
GTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
void processStdError(const QByteArray &outputLine) override;
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
void setCurrentTestSuite(const QString &testSuite);
|
||||
void handleDescriptionAndReportResult(TestResultPtr testResult);
|
||||
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_currentTestSuite;
|
||||
QString m_currentTestCase;
|
||||
QString m_description;
|
||||
|
@@ -88,7 +88,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document)
|
||||
}
|
||||
|
||||
bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull() || !includesGTest(doc, m_cppSnapshot) || !hasGTestNames(doc))
|
||||
@@ -96,18 +96,18 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInt
|
||||
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QString &filePath = doc->fileName();
|
||||
const QByteArray &fileContent = getFileContent(filePath);
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, filePath);
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName);
|
||||
document->check();
|
||||
CPlusPlus::AST *ast = document->translationUnit()->ast();
|
||||
GTestVisitor visitor(document);
|
||||
visitor.accept(ast);
|
||||
|
||||
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||
QString proFile;
|
||||
Utils::FilePath proFile;
|
||||
const QList<CppTools::ProjectPart::Ptr> &ppList = modelManager->projectPart(filePath);
|
||||
if (!ppList.isEmpty())
|
||||
proFile = ppList.first()->projectFile;
|
||||
proFile = Utils::FilePath::fromString(ppList.first()->projectFile);
|
||||
else
|
||||
return false; // happens if shutting down while parsing
|
||||
|
||||
@@ -115,7 +115,7 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInt
|
||||
const GTestCaseSpec &testSpec = it.key();
|
||||
GTestParseResult *parseResult = new GTestParseResult(framework());
|
||||
parseResult->itemType = TestTreeItem::TestSuite;
|
||||
parseResult->fileName = filePath;
|
||||
parseResult->fileName = fileName;
|
||||
parseResult->name = testSpec.testCaseName;
|
||||
parseResult->parameterized = testSpec.parameterized;
|
||||
parseResult->typed = testSpec.typed;
|
||||
@@ -125,7 +125,7 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInt
|
||||
for (const GTestCodeLocationAndType &location : it.value()) {
|
||||
GTestParseResult *testSet = new GTestParseResult(framework());
|
||||
testSet->name = location.m_name;
|
||||
testSet->fileName = filePath;
|
||||
testSet->fileName = fileName;
|
||||
testSet->line = location.m_line;
|
||||
testSet->column = location.m_column;
|
||||
testSet->disabled = location.m_state & GTestTreeItem::Disabled;
|
||||
|
@@ -45,7 +45,7 @@ class GTestParser : public CppParser
|
||||
public:
|
||||
explicit GTestParser(ITestFramework *framework) : CppParser(framework) {}
|
||||
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) override;
|
||||
const Utils::FilePath &fileName) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,7 +36,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
GTestResult::GTestResult(const QString &id, const QString &projectFile,
|
||||
GTestResult::GTestResult(const QString &id, const Utils::FilePath &projectFile,
|
||||
const QString &name)
|
||||
: TestResult(id, name), m_projectFile(projectFile)
|
||||
{
|
||||
|
@@ -36,7 +36,7 @@ namespace Internal {
|
||||
class GTestResult : public TestResult
|
||||
{
|
||||
public:
|
||||
GTestResult(const QString &id, const QString &projectFile, const QString &name);
|
||||
GTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name);
|
||||
const QString outputString(bool selected) const override;
|
||||
|
||||
void setTestCaseName(const QString &testSetName) { m_testCaseName = testSetName; }
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
bool matchesTestSuite(const TestTreeItem *treeItem) const;
|
||||
|
||||
QString m_testCaseName;
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
int m_iteration = 1;
|
||||
};
|
||||
|
||||
|
@@ -139,7 +139,7 @@ QVariant GTestTreeItem::data(int column, int role) const
|
||||
case Qt::ToolTipRole:
|
||||
if (type() == GroupNode
|
||||
&& GTestFramework::groupMode() == GTest::Constants::GTestFilter) {
|
||||
const auto tpl = QString("<p>%1</p><p>%2</p>").arg(filePath());
|
||||
const auto tpl = QString("<p>%1</p><p>%2</p>").arg(filePath().toString());
|
||||
return tpl.arg(QCoreApplication::translate(
|
||||
"GTestTreeItem", "Change GTest filter in use inside the settings."));
|
||||
}
|
||||
@@ -217,7 +217,7 @@ struct GTestCases
|
||||
};
|
||||
|
||||
static void collectTestInfo(const GTestTreeItem *item,
|
||||
QHash<QString, GTestCases> &testCasesForProFile,
|
||||
QHash<Utils::FilePath, GTestCases> &testCasesForProFile,
|
||||
bool ignoreCheckState)
|
||||
{
|
||||
QTC_ASSERT(item, return);
|
||||
@@ -232,7 +232,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
||||
QTC_ASSERT(childCount != 0, return);
|
||||
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
||||
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
||||
const QString &projectFile = item->childItem(0)->proFile();
|
||||
const Utils::FilePath &projectFile = item->childItem(0)->proFile();
|
||||
testCasesForProFile[projectFile].filters.append(
|
||||
gtestFilter(item->state()).arg(item->name()).arg('*'));
|
||||
testCasesForProFile[projectFile].testSetCount += childCount - 1;
|
||||
@@ -251,7 +251,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
||||
}
|
||||
|
||||
static void collectFailedTestInfo(const GTestTreeItem *item,
|
||||
QHash<QString, GTestCases> &testCasesForProfile)
|
||||
QHash<Utils::FilePath, GTestCases> &testCasesForProfile)
|
||||
{
|
||||
QTC_ASSERT(item, return);
|
||||
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
||||
@@ -276,7 +276,7 @@ QList<ITestConfiguration *> GTestTreeItem::getTestConfigurations(bool ignoreChec
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, GTestCases> testCasesForProFile;
|
||||
QHash<Utils::FilePath, GTestCases> testCasesForProFile;
|
||||
for (int row = 0, count = childCount(); row < count; ++row) {
|
||||
auto child = static_cast<const GTestTreeItem *>(childAt(row));
|
||||
collectTestInfo(child, testCasesForProFile, ignoreCheckState);
|
||||
@@ -315,7 +315,7 @@ QList<ITestConfiguration *> GTestTreeItem::getFailedTestConfigurations() const
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, GTestCases> testCasesForProFile;
|
||||
QHash<Utils::FilePath, GTestCases> testCasesForProFile;
|
||||
collectFailedTestInfo(this, testCasesForProFile);
|
||||
|
||||
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
||||
@@ -340,10 +340,9 @@ QList<ITestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const Ut
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, GTestCases> testCases;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildItems([&testCases, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestCase && node->filePath() == file) {
|
||||
QHash<Utils::FilePath, GTestCases> testCases;
|
||||
forAllChildItems([&testCases, &fileName](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestCase && node->filePath() == fileName) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
const GTestTreeItem *testCase = static_cast<GTestTreeItem *>(node->parentItem());
|
||||
QTC_ASSERT(testCase->type() == Type::TestSuite, return);
|
||||
@@ -381,8 +380,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
|
||||
case Root:
|
||||
if (result->framework->grouping()) {
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
const QFileInfo fileInfo(parseResult->fileName);
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
const Utils::FilePath base = parseResult->fileName.absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
GTestTreeItem *group = static_cast<GTestTreeItem *>(childAt(row));
|
||||
if (group->filePath() != base.absoluteFilePath())
|
||||
@@ -466,9 +464,9 @@ bool GTestTreeItem::modify(const TestParseResult *result)
|
||||
TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new GTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
const QFileInfo base = filePath().absolutePath().toFileInfo();
|
||||
return new GTestTreeItem(framework(), base.baseName(), filePath().absolutePath(),
|
||||
TestTreeItem::GroupNode);
|
||||
} else { // GTestFilter
|
||||
QTC_ASSERT(childCount(), return nullptr); // paranoia
|
||||
const TestTreeItem *firstChild = childItem(0);
|
||||
@@ -476,7 +474,10 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||
const QString fullTestName = name() + '.' + firstChild->name();
|
||||
const QString groupNodeName =
|
||||
matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString();
|
||||
auto groupNode = new GTestTreeItem(framework(), groupNodeName, activeFilter, TestTreeItem::GroupNode);
|
||||
// FIXME activeFilter is not a FilePath
|
||||
auto groupNode = new GTestTreeItem(framework(), groupNodeName,
|
||||
Utils::FilePath::fromString(activeFilter),
|
||||
TestTreeItem::GroupNode);
|
||||
if (groupNodeName == notMatchingString())
|
||||
groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole);
|
||||
return groupNode;
|
||||
@@ -497,7 +498,7 @@ bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result)
|
||||
|
||||
TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
||||
GTestTreeItem::TestStates state,
|
||||
const QString &proFile) const
|
||||
const Utils::FilePath &proFile) const
|
||||
{
|
||||
return findFirstLevelChildItem([name, state, proFile](const TestTreeItem *other) {
|
||||
const GTestTreeItem *gtestItem = static_cast<const GTestTreeItem *>(other);
|
||||
@@ -524,18 +525,19 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
||||
QSet<QString> result;
|
||||
const auto cppMM = CppTools::CppModelManager::instance();
|
||||
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
||||
const QString file = item.filePath();
|
||||
const Utils::FilePath filePath = item.filePath();
|
||||
const QString file = filePath.toString();
|
||||
const QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo.projectParts();
|
||||
if (projectParts.isEmpty())
|
||||
return cppMM->dependingInternalTargets(file);
|
||||
return cppMM->dependingInternalTargets(item.filePath());
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) {
|
||||
if (projectPart->projectFile == item.proFile()
|
||||
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
||||
&& Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) {
|
||||
return pf.path == file;
|
||||
})) {
|
||||
result.insert(projectPart->buildSystemTarget);
|
||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
result.unite(cppMM->dependingInternalTargets(file));
|
||||
result.unite(cppMM->dependingInternalTargets(filePath));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -548,7 +550,7 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
return false;
|
||||
|
||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||
return QFileInfo(other->filePath()).absolutePath() == filePath();
|
||||
return other->filePath().absolutePath() == filePath();
|
||||
} else { // GTestFilter
|
||||
QString fullName;
|
||||
if (other->type() == TestSuite) {
|
||||
@@ -563,9 +565,10 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
} else {
|
||||
QTC_ASSERT(false, return false);
|
||||
}
|
||||
if (GTestFramework::currentGTestFilter() != filePath()) // filter has changed in settings
|
||||
// FIXME gtest filter is no FilePath
|
||||
if (GTestFramework::currentGTestFilter() != filePath().toString()) // filter has changed in settings
|
||||
return false;
|
||||
bool matches = matchesFilter(filePath(), fullName);
|
||||
bool matches = matchesFilter(filePath().toString(), fullName);
|
||||
return (matches && name() == matchingString())
|
||||
|| (!matches && name() == notMatchingString());
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
explicit GTestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type), m_state(Enabled)
|
||||
{}
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
TestStates state() const { return m_state; }
|
||||
TestTreeItem *findChildByNameStateAndFile(const QString &name,
|
||||
GTestTreeItem::TestStates state,
|
||||
const QString &proFile) const;
|
||||
const Utils::FilePath &proFile) const;
|
||||
QString nameSuffix() const;
|
||||
bool isGroupNodeFor(const TestTreeItem *other) const override;
|
||||
bool isGroupable() const override;
|
||||
|
@@ -36,7 +36,7 @@ CppParser::CppParser(ITestFramework *framework)
|
||||
{
|
||||
}
|
||||
|
||||
void CppParser::init(const QStringList &filesToParse, bool fullParse)
|
||||
void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
||||
{
|
||||
Q_UNUSED(filesToParse)
|
||||
Q_UNUSED(fullParse)
|
||||
@@ -44,7 +44,7 @@ void CppParser::init(const QStringList &filesToParse, bool fullParse)
|
||||
m_workingCopy = CppTools::CppModelManager::instance()->workingCopy();
|
||||
}
|
||||
|
||||
bool CppParser::selectedForBuilding(const QString &fileName)
|
||||
bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
||||
{
|
||||
QList<CppTools::ProjectPart::Ptr> projParts =
|
||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||
@@ -52,7 +52,7 @@ bool CppParser::selectedForBuilding(const QString &fileName)
|
||||
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
||||
}
|
||||
|
||||
QByteArray CppParser::getFileContent(const QString &filePath) const
|
||||
QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const
|
||||
{
|
||||
QByteArray fileContent;
|
||||
if (m_workingCopy.contains(filePath)) {
|
||||
@@ -60,11 +60,8 @@ QByteArray CppParser::getFileContent(const QString &filePath) const
|
||||
} else {
|
||||
QString error;
|
||||
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
||||
if (Utils::TextFileFormat::readFileUTF8(Utils::FilePath::fromString(filePath),
|
||||
codec,
|
||||
&fileContent,
|
||||
&error)
|
||||
!= Utils::TextFileFormat::ReadSuccess) {
|
||||
if (Utils::TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error)
|
||||
!= Utils::TextFileFormat::ReadSuccess) {
|
||||
qDebug() << "Failed to read file" << filePath << ":" << error;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +75,7 @@ void CppParser::release()
|
||||
m_workingCopy = CppTools::WorkingCopy();
|
||||
}
|
||||
|
||||
CPlusPlus::Document::Ptr CppParser::document(const QString &fileName)
|
||||
CPlusPlus::Document::Ptr CppParser::document(const Utils::FilePath &fileName)
|
||||
{
|
||||
return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr;
|
||||
}
|
||||
|
@@ -49,8 +49,8 @@ public:
|
||||
ITestFramework *framework;
|
||||
TestTreeItem::Type itemType = TestTreeItem::Root;
|
||||
QString displayName;
|
||||
QString fileName;
|
||||
QString proFile;
|
||||
Utils::FilePath fileName;
|
||||
Utils::FilePath proFile;
|
||||
QString name;
|
||||
int line = 0;
|
||||
int column = 0;
|
||||
@@ -63,9 +63,9 @@ class ITestParser
|
||||
public:
|
||||
explicit ITestParser(ITestFramework *framework) : m_framework(framework) {}
|
||||
virtual ~ITestParser() { }
|
||||
virtual void init(const QStringList &filesToParse, bool fullParse) = 0;
|
||||
virtual void init(const Utils::FilePaths &filesToParse, bool fullParse) = 0;
|
||||
virtual bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) = 0;
|
||||
const Utils::FilePath &fileName) = 0;
|
||||
virtual void release() = 0;
|
||||
|
||||
ITestFramework *framework() const { return m_framework; }
|
||||
@@ -78,12 +78,12 @@ class CppParser : public ITestParser
|
||||
{
|
||||
public:
|
||||
explicit CppParser(ITestFramework *framework);
|
||||
void init(const QStringList &filesToParse, bool fullParse) override;
|
||||
static bool selectedForBuilding(const QString &fileName);
|
||||
QByteArray getFileContent(const QString &filePath) const;
|
||||
void init(const Utils::FilePaths &filesToParse, bool fullParse) override;
|
||||
static bool selectedForBuilding(const Utils::FilePath &fileName);
|
||||
QByteArray getFileContent(const Utils::FilePath &filePath) const;
|
||||
void release() override;
|
||||
|
||||
CPlusPlus::Document::Ptr document(const QString &fileName);
|
||||
CPlusPlus::Document::Ptr document(const Utils::FilePath &fileName);
|
||||
|
||||
protected:
|
||||
CPlusPlus::Snapshot m_cppSnapshot;
|
||||
|
@@ -47,9 +47,10 @@ bool isQTestMacro(const QByteArray ¯o)
|
||||
return valid.contains(macro);
|
||||
}
|
||||
|
||||
QHash<QString, QString> testCaseNamesForFiles(ITestFramework *framework, const QStringList &files)
|
||||
QHash<Utils::FilePath, QString> testCaseNamesForFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files)
|
||||
{
|
||||
QHash<QString, QString> result;
|
||||
QHash<Utils::FilePath, QString> result;
|
||||
TestTreeItem *rootNode = framework->rootNode();
|
||||
QTC_ASSERT(rootNode, return result);
|
||||
|
||||
@@ -64,17 +65,18 @@ QHash<QString, QString> testCaseNamesForFiles(ITestFramework *framework, const Q
|
||||
return result;
|
||||
}
|
||||
|
||||
QMultiHash<QString, QString> alternativeFiles(ITestFramework *framework, const QStringList &files)
|
||||
QMultiHash<Utils::FilePath, Utils::FilePath> alternativeFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files)
|
||||
{
|
||||
QMultiHash<QString, QString> result;
|
||||
QMultiHash<Utils::FilePath, Utils::FilePath> result;
|
||||
TestTreeItem *rootNode = framework->rootNode();
|
||||
QTC_ASSERT(rootNode, return result);
|
||||
|
||||
rootNode->forFirstLevelChildren([&result, &files](ITestTreeItem *child) {
|
||||
const QString &baseFilePath = child->filePath();
|
||||
const Utils::FilePath &baseFilePath = child->filePath();
|
||||
for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) {
|
||||
auto grandChild = static_cast<const QtTestTreeItem *>(child->childAt(childRow));
|
||||
const QString &filePath = grandChild->filePath();
|
||||
const Utils::FilePath &filePath = grandChild->filePath();
|
||||
if (grandChild->inherited() && baseFilePath != filePath && files.contains(filePath)) {
|
||||
if (!result.contains(filePath, baseFilePath))
|
||||
result.insert(filePath, baseFilePath);
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace Utils { class Environment; }
|
||||
@@ -37,8 +39,10 @@ namespace Internal {
|
||||
namespace QTestUtils {
|
||||
|
||||
bool isQTestMacro(const QByteArray ¯o);
|
||||
QHash<QString, QString> testCaseNamesForFiles(ITestFramework *framework, const QStringList &files);
|
||||
QMultiHash<QString, QString> alternativeFiles(ITestFramework *framework, const QStringList &files);
|
||||
QHash<Utils::FilePath, QString> testCaseNamesForFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files);
|
||||
QMultiHash<Utils::FilePath, Utils::FilePath> alternativeFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files);
|
||||
QStringList filterInterfering(const QStringList &provided, QStringList *omitted, bool isQuickTest);
|
||||
Utils::Environment prepareBasicEnvironment(const Utils::Environment &env);
|
||||
|
||||
|
@@ -42,7 +42,7 @@ ITestTreeItem *QtTestFramework::createRootNode()
|
||||
this,
|
||||
QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
|
@@ -125,14 +125,11 @@ static QString constructBenchmarkInformation(const QString &metric, double value
|
||||
.arg(iterations);
|
||||
}
|
||||
|
||||
static QString constructSourceFilePath(const QString &path, const QString &filePath)
|
||||
{
|
||||
return QFileInfo(path, filePath).canonicalFilePath();
|
||||
}
|
||||
|
||||
QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile, OutputMode mode, TestType type)
|
||||
QProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile,
|
||||
OutputMode mode, TestType type)
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
, m_projectFile(projectFile)
|
||||
, m_mode(mode)
|
||||
@@ -237,9 +234,8 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
const QXmlStreamAttributes &attributes = m_xmlReader.attributes();
|
||||
m_result = TestResult::resultFromString(
|
||||
attributes.value(QStringLiteral("type")).toString());
|
||||
m_file = decode(attributes.value(QStringLiteral("file")).toString());
|
||||
if (!m_file.isEmpty())
|
||||
m_file = constructSourceFilePath(m_buildDir, m_file);
|
||||
const QString file = decode(attributes.value(QStringLiteral("file")).toString());
|
||||
m_file = constructSourceFilePath(m_buildDir, file);
|
||||
m_lineNumber = attributes.value(QStringLiteral("line")).toInt();
|
||||
} else if (currentTag == QStringLiteral("BenchmarkResult")) {
|
||||
const QXmlStreamAttributes &attributes = m_xmlReader.attributes();
|
||||
|
@@ -48,8 +48,8 @@ public:
|
||||
};
|
||||
|
||||
QtTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory,
|
||||
const QString &projectFile, OutputMode mode, TestType type);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile, OutputMode mode, TestType type);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
TestResultPtr createDefaultResult() const override;
|
||||
@@ -78,14 +78,14 @@ private:
|
||||
};
|
||||
|
||||
CDATAMode m_cdataMode = None;
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_className;
|
||||
QString m_testCase;
|
||||
QString m_formerTestCase;
|
||||
QString m_dataTag;
|
||||
ResultType m_result = ResultType::Invalid;
|
||||
QString m_description;
|
||||
QString m_file;
|
||||
Utils::FilePath m_file;
|
||||
int m_lineNumber = 0;
|
||||
QString m_duration;
|
||||
QXmlStreamReader m_xmlReader;
|
||||
|
@@ -81,7 +81,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool qtTestLibDefined(const QString &fileName)
|
||||
static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
||||
{
|
||||
const QList<CppTools::ProjectPart::Ptr> parts =
|
||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||
@@ -93,10 +93,11 @@ static bool qtTestLibDefined(const QString &fileName)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager, const QString &fileName) const
|
||||
QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager,
|
||||
const Utils::FilePath &fileName) const
|
||||
{
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
CPlusPlus::Document::Ptr document = modelManager->document(fileName);
|
||||
CPlusPlus::Document::Ptr document = modelManager->document(fileName.toString());
|
||||
if (document.isNull())
|
||||
return QString();
|
||||
|
||||
@@ -124,7 +125,7 @@ QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager, c
|
||||
static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const QString &testCaseName,
|
||||
const QStringList &alternativeFiles = {},
|
||||
const Utils::FilePaths &alternativeFiles = {},
|
||||
int *line = nullptr,
|
||||
int *column = nullptr)
|
||||
{
|
||||
@@ -136,7 +137,7 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
||||
doc->globalNamespace());
|
||||
// fallback for inherited functions
|
||||
if (lookupItems.size() == 0 && !alternativeFiles.isEmpty()) {
|
||||
for (const QString &alternativeFile : alternativeFiles) {
|
||||
for (const Utils::FilePath &alternativeFile : alternativeFiles) {
|
||||
if (snapshot.contains(alternativeFile)) {
|
||||
CPlusPlus::Document::Ptr document = snapshot.document(alternativeFile);
|
||||
CPlusPlus::TypeOfExpression typeOfExpr; // we need a new one with no bindings
|
||||
@@ -181,7 +182,7 @@ static QSet<QString> filesWithDataFunctionDefinitions(
|
||||
|
||||
QHash<QString, QtTestCodeLocationList> QtTestParser::checkForDataTags(const QString &fileName) const
|
||||
{
|
||||
const QByteArray fileContent = getFileContent(fileName);
|
||||
const QByteArray fileContent = getFileContent(Utils::FilePath::fromString(fileName));
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName);
|
||||
document->check();
|
||||
CPlusPlus::AST *ast = document->translationUnit()->ast();
|
||||
@@ -278,7 +279,7 @@ static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc)
|
||||
}
|
||||
|
||||
bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull())
|
||||
@@ -314,7 +315,8 @@ Utils::optional<bool> QtTestParser::fillTestCaseData(
|
||||
const QString &testCaseName, const CPlusPlus::Document::Ptr &doc,
|
||||
TestCaseData &data) const
|
||||
{
|
||||
const QStringList &alternativeFiles = m_alternativeFiles.values(doc->fileName());
|
||||
const Utils::FilePath filePath = Utils::FilePath::fromString(doc->fileName());
|
||||
const Utils::FilePaths &alternativeFiles = m_alternativeFiles.values(filePath);
|
||||
CPlusPlus::Document::Ptr declaringDoc = declaringDocument(doc, m_cppSnapshot, testCaseName,
|
||||
alternativeFiles,
|
||||
&(data.line), &(data.column));
|
||||
@@ -341,7 +343,7 @@ Utils::optional<bool> QtTestParser::fillTestCaseData(
|
||||
for (const QString &file : files)
|
||||
Utils::addToHash(&(data.dataTags), checkForDataTags(file));
|
||||
|
||||
data.fileName = declaringDoc->fileName();
|
||||
data.fileName = Utils::FilePath::fromString(declaringDoc->fileName());
|
||||
data.valid = true;
|
||||
return Utils::optional<bool>();
|
||||
}
|
||||
@@ -356,7 +358,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
||||
parseResult->displayName = testCaseName;
|
||||
parseResult->line = data.line;
|
||||
parseResult->column = data.column;
|
||||
parseResult->proFile = projectFile;
|
||||
parseResult->proFile = Utils::FilePath::fromString(projectFile);
|
||||
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin();
|
||||
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end();
|
||||
for ( ; it != end; ++it) {
|
||||
@@ -367,7 +369,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
||||
func->itemType = location.m_type;
|
||||
func->name = testCaseName + "::" + functionName;
|
||||
func->displayName = functionName;
|
||||
func->fileName = location.m_name;
|
||||
func->fileName = Utils::FilePath::fromString(location.m_name);
|
||||
func->line = location.m_line;
|
||||
func->column = location.m_column;
|
||||
func->setInherited(location.m_inherited);
|
||||
@@ -378,7 +380,8 @@ QtTestParseResult *QtTestParser::createParseResult(
|
||||
dataTag->itemType = tag.m_type;
|
||||
dataTag->name = tag.m_name;
|
||||
dataTag->displayName = tag.m_name;
|
||||
dataTag->fileName = data.testFunctions.value(it.key() + "_data").m_name;
|
||||
dataTag->fileName = Utils::FilePath::fromString(
|
||||
data.testFunctions.value(it.key() + "_data").m_name);
|
||||
dataTag->line = tag.m_line;
|
||||
dataTag->column = tag.m_column;
|
||||
dataTag->setInherited(tag.m_inherited);
|
||||
@@ -390,7 +393,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
||||
return parseResult;
|
||||
}
|
||||
|
||||
void QtTestParser::init(const QStringList &filesToParse, bool fullParse)
|
||||
void QtTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
||||
{
|
||||
if (!fullParse) { // in a full parse cached information might lead to wrong results
|
||||
m_testCaseNames = QTestUtils::testCaseNamesForFiles(framework(), filesToParse);
|
||||
|
@@ -52,16 +52,17 @@ class QtTestParser : public CppParser
|
||||
public:
|
||||
explicit QtTestParser(ITestFramework *framework) : CppParser(framework) {}
|
||||
|
||||
void init(const QStringList &filesToParse, bool fullParse) override;
|
||||
void init(const Utils::FilePaths &filesToParse, bool fullParse) override;
|
||||
void release() override;
|
||||
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) override;
|
||||
const Utils::FilePath &fileName) override;
|
||||
|
||||
private:
|
||||
QString testClass(const CppTools::CppModelManager *modelManager, const QString &fileName) const;
|
||||
QString testClass(const CppTools::CppModelManager *modelManager,
|
||||
const Utils::FilePath &fileName) const;
|
||||
QHash<QString, QtTestCodeLocationList> checkForDataTags(const QString &fileName) const;
|
||||
struct TestCaseData {
|
||||
QString fileName;
|
||||
Utils::FilePath fileName;
|
||||
int line = 0;
|
||||
int column = 0;
|
||||
QMap<QString, QtTestCodeLocationAndType> testFunctions;
|
||||
@@ -74,8 +75,8 @@ private:
|
||||
TestCaseData &data) const;
|
||||
QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data,
|
||||
const QString &projectFile) const;
|
||||
QHash<QString, QString> m_testCaseNames;
|
||||
QMultiHash<QString, QString> m_alternativeFiles;
|
||||
QHash<Utils::FilePath, QString> m_testCaseNames;
|
||||
QMultiHash<Utils::FilePath, Utils::FilePath> m_alternativeFiles;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -34,7 +34,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QtTestResult::QtTestResult(const QString &id, const QString &projectFile, TestType type,
|
||||
QtTestResult::QtTestResult(const QString &id, const Utils::FilePath &projectFile, TestType type,
|
||||
const QString &className)
|
||||
: TestResult(id, className), m_projectFile(projectFile), m_type(type)
|
||||
{
|
||||
|
@@ -37,7 +37,7 @@ namespace Internal {
|
||||
class QtTestResult : public TestResult
|
||||
{
|
||||
public:
|
||||
QtTestResult(const QString &id, const QString &projectFile, TestType type,
|
||||
QtTestResult(const QString &id, const Utils::FilePath &projectFile, TestType type,
|
||||
const QString &className);
|
||||
const QString outputString(bool selected) const override;
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
QString m_function;
|
||||
QString m_dataTag;
|
||||
QString m_projectFile;
|
||||
Utils::FilePath m_projectFile;
|
||||
TestType m_type;
|
||||
};
|
||||
|
||||
|
@@ -36,7 +36,7 @@ namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name,
|
||||
const QString &filePath, TestTreeItem::Type type)
|
||||
const Utils::FilePath &filePath, TestTreeItem::Type type)
|
||||
: TestTreeItem(testFramework, name, filePath, type)
|
||||
{
|
||||
if (type == TestDataTag)
|
||||
@@ -291,9 +291,8 @@ QList<ITestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const U
|
||||
return result;
|
||||
|
||||
QHash<TestTreeItem *, QStringList> testFunctions;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildItems([&testFunctions, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunction && node->filePath() == file) {
|
||||
forAllChildItems([&testFunctions, &fileName](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunction && node->filePath() == fileName) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
TestTreeItem *testCase = node->parentItem();
|
||||
QTC_ASSERT(testCase->type() == Type::TestCase, return);
|
||||
@@ -318,7 +317,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
|
||||
switch (type()) {
|
||||
case Root:
|
||||
if (result->framework->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
const Utils::FilePath path = result->fileName.absolutePath();
|
||||
for (int row = 0; row < childCount(); ++row) {
|
||||
TestTreeItem *group = childItem(row);
|
||||
if (group->filePath() != path)
|
||||
@@ -357,7 +356,7 @@ TestTreeItem *QtTestTreeItem::findChild(const TestTreeItem *other)
|
||||
if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction)
|
||||
return nullptr;
|
||||
auto qtOther = static_cast<const QtTestTreeItem *>(other);
|
||||
return findChildByNameAndInheritance(other->filePath(), qtOther->inherited());
|
||||
return findChildByNameAndInheritance(other->name(), qtOther->inherited());
|
||||
}
|
||||
case TestFunction:
|
||||
case TestDataFunction:
|
||||
@@ -388,9 +387,8 @@ bool QtTestTreeItem::modify(const TestParseResult *result)
|
||||
|
||||
TestTreeItem *QtTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new QtTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
const QFileInfo base = filePath().absolutePath().toFileInfo();
|
||||
return new QtTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
bool QtTestTreeItem::isGroupable() const
|
||||
|
@@ -34,7 +34,7 @@ class QtTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(),
|
||||
const QString &filePath = QString(), Type type = Root);
|
||||
const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root);
|
||||
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
QVariant data(int column, int role) const override;
|
||||
|
@@ -43,9 +43,10 @@ bool isQuickTestMacro(const QByteArray ¯o)
|
||||
return valid.contains(macro);
|
||||
}
|
||||
|
||||
QHash<QString, QString> proFilesForQmlFiles(ITestFramework *framework, const QStringList &files)
|
||||
QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files)
|
||||
{
|
||||
QHash<QString, QString> result;
|
||||
QHash<Utils::FilePath, Utils::FilePath> result;
|
||||
TestTreeItem *rootNode = framework->rootNode();
|
||||
QTC_ASSERT(rootNode, return result);
|
||||
|
||||
@@ -53,16 +54,16 @@ QHash<QString, QString> proFilesForQmlFiles(ITestFramework *framework, const QSt
|
||||
return result;
|
||||
|
||||
rootNode->forFirstLevelChildItems([&result, &files](TestTreeItem *child) {
|
||||
const QString &file = child->filePath();
|
||||
const Utils::FilePath &file = child->filePath();
|
||||
if (!file.isEmpty() && files.contains(file)) {
|
||||
const QString &proFile = child->proFile();
|
||||
const Utils::FilePath &proFile = child->proFile();
|
||||
if (!proFile.isEmpty())
|
||||
result.insert(file, proFile);
|
||||
}
|
||||
child->forFirstLevelChildItems([&result, &files](TestTreeItem *grandChild) {
|
||||
const QString &file = grandChild->filePath();
|
||||
const Utils::FilePath &file = grandChild->filePath();
|
||||
if (!file.isEmpty() && files.contains(file)) {
|
||||
const QString &proFile = grandChild->proFile();
|
||||
const Utils::FilePath &proFile = grandChild->proFile();
|
||||
if (!proFile.isEmpty())
|
||||
result.insert(file, proFile);
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace Autotest {
|
||||
@@ -35,7 +37,8 @@ namespace Internal {
|
||||
namespace QuickTestUtils {
|
||||
|
||||
bool isQuickTestMacro(const QByteArray ¯o);
|
||||
QHash<QString, QString> proFilesForQmlFiles(ITestFramework *framework, const QStringList &files);
|
||||
QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *framework,
|
||||
const Utils::FilePaths &files);
|
||||
|
||||
} // namespace QuickTestUtils
|
||||
} // namespace Internal
|
||||
|
@@ -42,7 +42,7 @@ ITestParser *QuickTestFramework::createTestParser()
|
||||
ITestTreeItem *QuickTestFramework::createRootNode()
|
||||
{
|
||||
return new QuickTestTreeItem(this, QCoreApplication::translate("QuickTestFramework", "Quick Test"),
|
||||
QString(), ITestTreeItem::Root);
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QuickTestFramework::name() const
|
||||
|
@@ -91,7 +91,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
||||
}
|
||||
|
||||
static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
@@ -122,14 +122,14 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons
|
||||
const QByteArray name = macro.macro().name();
|
||||
if (QuickTestUtils::isQuickTestMacro(name)) {
|
||||
CPlusPlus::Document::Block arg = macro.arguments().at(0);
|
||||
return QLatin1String(getFileContent(doc->fileName())
|
||||
return QLatin1String(getFileContent(Utils::FilePath::fromString(doc->fileName()))
|
||||
.mid(int(arg.bytesBegin()), int(arg.bytesEnd() - arg.bytesBegin())));
|
||||
}
|
||||
}
|
||||
|
||||
// check for using quick_test_main() directly
|
||||
const QString fileName = doc->fileName();
|
||||
const QByteArray &fileContent = getFileContent(fileName);
|
||||
const QByteArray &fileContent = getFileContent(Utils::FilePath::fromString(fileName));
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName);
|
||||
if (document.isNull())
|
||||
return QString();
|
||||
@@ -182,7 +182,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const QS
|
||||
static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const Document::Ptr &qmlJSDoc,
|
||||
ITestFramework *framework,
|
||||
const QString &proFile = QString())
|
||||
const Utils::FilePath &proFile = Utils::FilePath())
|
||||
{
|
||||
if (qmlJSDoc.isNull())
|
||||
return false;
|
||||
@@ -203,7 +203,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
parseResult->proFile = proFile;
|
||||
parseResult->itemType = TestTreeItem::TestCase;
|
||||
if (!testCaseName.isEmpty()) {
|
||||
parseResult->fileName = testCase.m_locationAndType.m_name;
|
||||
parseResult->fileName = Utils::FilePath::fromString(testCase.m_locationAndType.m_name);
|
||||
parseResult->name = testCaseName;
|
||||
parseResult->line = testCase.m_locationAndType.m_line;
|
||||
parseResult->column = testCase.m_locationAndType.m_column;
|
||||
@@ -214,7 +214,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
funcResult->name = function.m_functionName;
|
||||
funcResult->displayName = function.m_functionName;
|
||||
funcResult->itemType = function.m_locationAndType.m_type;
|
||||
funcResult->fileName = function.m_locationAndType.m_name;
|
||||
funcResult->fileName = Utils::FilePath::fromString(function.m_locationAndType.m_name);
|
||||
funcResult->line = function.m_locationAndType.m_line;
|
||||
funcResult->column = function.m_locationAndType.m_column;
|
||||
funcResult->proFile = proFile;
|
||||
@@ -235,11 +235,11 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> fut
|
||||
if (quickTestName(document).isEmpty())
|
||||
return false;
|
||||
|
||||
const QString cppFileName = document->fileName();
|
||||
QList<CppTools::ProjectPart::Ptr> ppList = modelManager->projectPart(cppFileName);
|
||||
QList<CppTools::ProjectPart::Ptr> ppList = modelManager->projectPart(document->fileName());
|
||||
if (ppList.isEmpty()) // happens if shutting down while parsing
|
||||
return false;
|
||||
const QString &proFile = ppList.at(0)->projectFile;
|
||||
const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName());
|
||||
const Utils::FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile);
|
||||
m_mainCppFiles.insert(cppFileName, proFile);
|
||||
const QString srcDir = quickTestSrcDir(modelManager, cppFileName);
|
||||
if (srcDir.isEmpty())
|
||||
@@ -315,14 +315,14 @@ QuickTestParser::QuickTestParser(ITestFramework *framework)
|
||||
this, &QuickTestParser::handleDirectoryChanged);
|
||||
}
|
||||
|
||||
void QuickTestParser::init(const QStringList &filesToParse, bool fullParse)
|
||||
void QuickTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
||||
{
|
||||
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
||||
if (!fullParse) {
|
||||
// in a full parse we get the correct entry points by the respective main
|
||||
m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(framework(), filesToParse);
|
||||
// get rid of cached main cpp files that are going to get processed anyhow
|
||||
for (const QString &file : filesToParse) {
|
||||
for (const Utils::FilePath &file : filesToParse) {
|
||||
if (m_mainCppFiles.contains(file)) {
|
||||
m_mainCppFiles.remove(file);
|
||||
if (m_mainCppFiles.isEmpty())
|
||||
@@ -344,13 +344,13 @@ void QuickTestParser::release()
|
||||
}
|
||||
|
||||
bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
if (fileName.endsWith(".qml")) {
|
||||
const QString &proFile = m_proFilesForQmlFiles.value(fileName);
|
||||
const Utils::FilePath &proFile = m_proFilesForQmlFiles.value(fileName);
|
||||
if (proFile.isEmpty())
|
||||
return false;
|
||||
Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName);
|
||||
Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName.toString());
|
||||
return checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, framework(), proFile);
|
||||
}
|
||||
if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName))
|
||||
@@ -361,9 +361,9 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
||||
return handleQtQuickTest(futureInterface, document, framework());
|
||||
}
|
||||
|
||||
QString QuickTestParser::projectFileForMainCppFile(const QString &fileName) const
|
||||
Utils::FilePath QuickTestParser::projectFileForMainCppFile(const Utils::FilePath &fileName) const
|
||||
{
|
||||
return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : QString();
|
||||
return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : Utils::FilePath();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -46,11 +46,11 @@ class QuickTestParser : public QObject, public CppParser
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QuickTestParser(ITestFramework *framework);
|
||||
void init(const QStringList &filesToParse, bool fullParse) override;
|
||||
void init(const Utils::FilePaths &filesToParse, bool fullParse) override;
|
||||
void release() override;
|
||||
bool processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName) override;
|
||||
QString projectFileForMainCppFile(const QString &fileName) const;
|
||||
const Utils::FilePath &fileName) override;
|
||||
Utils::FilePath projectFileForMainCppFile(const Utils::FilePath &fileName) const;
|
||||
private:
|
||||
bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
CPlusPlus::Document::Ptr document, ITestFramework *framework);
|
||||
@@ -59,10 +59,10 @@ private:
|
||||
QString quickTestName(const CPlusPlus::Document::Ptr &doc) const;
|
||||
QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QString &srcDir);
|
||||
QmlJS::Snapshot m_qmlSnapshot;
|
||||
QHash<QString, QString> m_proFilesForQmlFiles;
|
||||
QHash<Utils::FilePath, Utils::FilePath> m_proFilesForQmlFiles;
|
||||
QFileSystemWatcher m_directoryWatcher;
|
||||
QMap<QString, QMap<QString, QDateTime> > m_watchedFiles;
|
||||
QMap<QString, QString> m_mainCppFiles;
|
||||
QMap<Utils::FilePath, Utils::FilePath> m_mainCppFiles;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,7 +36,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
QSet<QString> internalTargets(const QString &proFile);
|
||||
QSet<QString> internalTargets(const Utils::FilePath &proFile);
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::copyWithoutChildren()
|
||||
{
|
||||
@@ -170,7 +170,7 @@ static QList<ITestConfiguration *> testConfigurationsFor(
|
||||
if (!project || rootNode->type() != TestTreeItem::Root)
|
||||
return {};
|
||||
|
||||
QHash<QString, QuickTestConfiguration *> configurationForProFiles;
|
||||
QHash<Utils::FilePath, QuickTestConfiguration *> configurationForProFiles;
|
||||
rootNode->forSelectedChildren([&predicate, &configurationForProFiles](Utils::TreeItem *it) {
|
||||
auto treeItem = static_cast<TestTreeItem *>(it);
|
||||
if (treeItem->type() == TestTreeItem::Root || treeItem->type() == TestTreeItem::GroupNode)
|
||||
@@ -229,12 +229,12 @@ QList<ITestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<QString, Tests> testsForProfile;
|
||||
QHash<Utils::FilePath, Tests> testsForProfile;
|
||||
forFirstLevelChildItems([&testsForProfile](TestTreeItem *child) {
|
||||
// unnamed Quick Tests must be handled separately
|
||||
if (child->name().isEmpty()) {
|
||||
child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) {
|
||||
const QString &proFile = grandChild->proFile();
|
||||
const Utils::FilePath &proFile = grandChild->proFile();
|
||||
++(testsForProfile[proFile].testCount);
|
||||
testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile());
|
||||
});
|
||||
@@ -278,9 +278,8 @@ QList<ITestConfiguration *> QuickTestTreeItem::getFailedTestConfigurations() con
|
||||
QList<ITestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile(
|
||||
const Utils::FilePath &fileName) const
|
||||
{
|
||||
const QString &file = fileName.toString();
|
||||
return testConfigurationsFor(this, [&file](TestTreeItem *it) {
|
||||
return it->filePath() == file;
|
||||
return testConfigurationsFor(this, [&fileName](TestTreeItem *it) {
|
||||
return it->filePath() == fileName;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -293,7 +292,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
||||
if (result->name.isEmpty())
|
||||
return unnamedQuickTests();
|
||||
if (result->framework->grouping()) {
|
||||
const QString path = QFileInfo(result->fileName).absolutePath();
|
||||
const Utils::FilePath path = result->fileName.absolutePath();
|
||||
TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) {
|
||||
return group->filePath() == path;
|
||||
});
|
||||
@@ -376,9 +375,8 @@ bool QuickTestTreeItem::removeOnSweepIfEmpty() const
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
||||
{
|
||||
const QFileInfo fileInfo(filePath());
|
||||
const QFileInfo base(fileInfo.absolutePath());
|
||||
return new QuickTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode);
|
||||
const QFileInfo base = filePath().absolutePath().toFileInfo();
|
||||
return new QuickTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode);
|
||||
}
|
||||
|
||||
bool QuickTestTreeItem::isGroupable() const
|
||||
@@ -386,7 +384,7 @@ bool QuickTestTreeItem::isGroupable() const
|
||||
return type() == TestCase && !name().isEmpty() && !filePath().isEmpty();
|
||||
}
|
||||
|
||||
QSet<QString> internalTargets(const QString &proFile)
|
||||
QSet<QString> internalTargets(const Utils::FilePath &proFile)
|
||||
{
|
||||
QSet<QString> result;
|
||||
const auto cppMM = CppTools::CppModelManager::instance();
|
||||
@@ -394,17 +392,17 @@ QSet<QString> internalTargets(const QString &proFile)
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) {
|
||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
continue;
|
||||
if (projectPart->projectFile == proFile)
|
||||
if (projectPart->projectFile == proFile.toString())
|
||||
result.insert(projectPart->buildSystemTarget);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath)
|
||||
void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePath)
|
||||
{
|
||||
TestTreeItem::markForRemovalRecursively(filePath);
|
||||
auto parser = dynamic_cast<QuickTestParser *>(framework()->testParser());
|
||||
const QString proFile = parser->projectFileForMainCppFile(filePath);
|
||||
const Utils::FilePath proFile = parser->projectFileForMainCppFile(filePath);
|
||||
if (!proFile.isEmpty()) {
|
||||
TestTreeItem *root = framework()->rootNode();
|
||||
root->forAllChildItems([proFile](TestTreeItem *it) {
|
||||
@@ -414,7 +412,7 @@ void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath)
|
||||
}
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &filePath,
|
||||
TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &filePath,
|
||||
const QString &name,
|
||||
TestTreeItem::Type tType)
|
||||
|
||||
@@ -425,7 +423,8 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &fileP
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name,
|
||||
const QString &filePath, int line)
|
||||
const Utils::FilePath &filePath,
|
||||
int line)
|
||||
{
|
||||
return findFirstLevelChildItem([name, filePath, line](const TestTreeItem *other) {
|
||||
return other->filePath() == filePath && other->line() == line && other->name() == name;
|
||||
|
@@ -35,7 +35,7 @@ class QuickTestTreeItem : public TestTreeItem
|
||||
public:
|
||||
explicit QuickTestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type)
|
||||
{}
|
||||
@@ -59,11 +59,11 @@ public:
|
||||
bool removeOnSweepIfEmpty() const override;
|
||||
TestTreeItem *createParentGroupNode() const override;
|
||||
bool isGroupable() const override;
|
||||
void markForRemovalRecursively(const QString &filePath) override;
|
||||
void markForRemovalRecursively(const Utils::FilePath &filePath) override;
|
||||
private:
|
||||
TestTreeItem *findChildByFileNameAndType(const QString &filePath, const QString &name,
|
||||
TestTreeItem *findChildByFileNameAndType(const Utils::FilePath &filePath, const QString &name,
|
||||
Type tType);
|
||||
TestTreeItem *findChildByNameFileAndLine(const QString &name, const QString &filePath,
|
||||
TestTreeItem *findChildByNameFileAndLine(const QString &name, const Utils::FilePath &filePath,
|
||||
int line);
|
||||
TestTreeItem *unnamedQuickTests() const;
|
||||
};
|
||||
|
@@ -163,12 +163,12 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
||||
Utils::sort(sortedParsers, [](const ITestParser *lhs, const ITestParser *rhs) {
|
||||
return lhs->framework()->priority() < rhs->framework()->priority();
|
||||
});
|
||||
scanForTests(QStringList(), sortedParsers);
|
||||
scanForTests(Utils::FilePaths(), sortedParsers);
|
||||
}
|
||||
|
||||
/****** threaded parsing stuff *******/
|
||||
|
||||
void TestCodeParser::onDocumentUpdated(const QString &fileName, bool isQmlFile)
|
||||
void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile)
|
||||
{
|
||||
if (m_codeModelParsing || m_fullUpdatePostponed)
|
||||
return;
|
||||
@@ -177,22 +177,22 @@ void TestCodeParser::onDocumentUpdated(const QString &fileName, bool isQmlFile)
|
||||
if (!project)
|
||||
return;
|
||||
// Quick tests: qml files aren't necessarily listed inside project files
|
||||
if (!isQmlFile && !project->isKnownFile(Utils::FilePath::fromString(fileName)))
|
||||
if (!isQmlFile && !project->isKnownFile(fileName))
|
||||
return;
|
||||
|
||||
scanForTests(QStringList(fileName));
|
||||
scanForTests(Utils::FilePaths{fileName});
|
||||
}
|
||||
|
||||
void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
||||
{
|
||||
onDocumentUpdated(document->fileName());
|
||||
onDocumentUpdated(Utils::FilePath::fromString(document->fileName()));
|
||||
}
|
||||
|
||||
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
||||
{
|
||||
const QString fileName = document->fileName();
|
||||
if (!fileName.endsWith(".qbs"))
|
||||
onDocumentUpdated(fileName, true);
|
||||
onDocumentUpdated(Utils::FilePath::fromString(fileName), true);
|
||||
}
|
||||
|
||||
void TestCodeParser::onStartupProjectChanged(Project *project)
|
||||
@@ -227,7 +227,7 @@ void TestCodeParser::aboutToShutdown()
|
||||
}
|
||||
}
|
||||
|
||||
bool TestCodeParser::postponed(const QStringList &fileList)
|
||||
bool TestCodeParser::postponed(const Utils::FilePaths &fileList)
|
||||
{
|
||||
switch (m_parserState) {
|
||||
case Idle:
|
||||
@@ -270,7 +270,7 @@ bool TestCodeParser::postponed(const QStringList &fileList)
|
||||
if (m_fullUpdatePostponed)
|
||||
return true;
|
||||
// partial parse triggered, postpone or add current files to already postponed partial
|
||||
for (const QString &file : fileList)
|
||||
for (const Utils::FilePath &file : fileList)
|
||||
m_postponedFiles.insert(file);
|
||||
m_partialUpdatePostponed = true;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ bool TestCodeParser::postponed(const QStringList &fileList)
|
||||
|
||||
static void parseFileForTests(const QList<ITestParser *> &parsers,
|
||||
QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||
const QString &fileName)
|
||||
const Utils::FilePath &fileName)
|
||||
{
|
||||
for (ITestParser *parser : parsers) {
|
||||
if (futureInterface.isCanceled())
|
||||
@@ -293,7 +293,8 @@ static void parseFileForTests(const QList<ITestParser *> &parsers,
|
||||
}
|
||||
}
|
||||
|
||||
void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITestParser *> &parsers)
|
||||
void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
||||
const QList<ITestParser *> &parsers)
|
||||
{
|
||||
if (m_parserState == Shutdown || m_testCodeParsers.isEmpty())
|
||||
return;
|
||||
@@ -308,9 +309,9 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITest
|
||||
Project *project = SessionManager::startupProject();
|
||||
if (!project)
|
||||
return;
|
||||
QStringList list;
|
||||
Utils::FilePaths list;
|
||||
if (isFullParse) {
|
||||
list = Utils::transform(project->files(Project::SourceFiles), &Utils::FilePath::toString);
|
||||
list = project->files(Project::SourceFiles);
|
||||
if (list.isEmpty()) {
|
||||
// at least project file should be there, but might happen if parsing current project
|
||||
// takes too long, especially when opening sessions holding multiple projects
|
||||
@@ -330,7 +331,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITest
|
||||
TestTreeModel::instance()->updateCheckStateCache();
|
||||
if (isFullParse) {
|
||||
// remove qml files as they will be found automatically by the referencing cpp file
|
||||
list = Utils::filtered(list, [] (const QString &fn) {
|
||||
list = Utils::filtered(list, [] (const Utils::FilePath &fn) {
|
||||
return !fn.endsWith(".qml");
|
||||
});
|
||||
if (!parsers.isEmpty()) {
|
||||
@@ -342,12 +343,11 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITest
|
||||
}
|
||||
} else if (!parsers.isEmpty()) {
|
||||
for (ITestParser *parser: parsers) {
|
||||
for (const QString &filePath : qAsConst(list)) {
|
||||
for (const Utils::FilePath &filePath : qAsConst(list))
|
||||
parser->framework()->rootNode()->markForRemovalRecursively(filePath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const QString &filePath : qAsConst(list))
|
||||
for (const Utils::FilePath &filePath : qAsConst(list))
|
||||
emit requestRemoval(filePath);
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QList<ITest
|
||||
parser->init(list, isFullParse);
|
||||
|
||||
QFuture<TestParseResultPtr> future = Utils::map(list,
|
||||
[codeParsers](QFutureInterface<TestParseResultPtr> &fi, const QString &file) {
|
||||
[codeParsers](QFutureInterface<TestParseResultPtr> &fi, const Utils::FilePath &file) {
|
||||
parseFileForTests(codeParsers, fi, file);
|
||||
},
|
||||
Utils::MapReduceOption::Unordered,
|
||||
|
@@ -74,7 +74,7 @@ signals:
|
||||
void parsingStarted();
|
||||
void parsingFinished();
|
||||
void parsingFailed();
|
||||
void requestRemoval(const QString &filePath);
|
||||
void requestRemoval(const Utils::FilePath &filePath);
|
||||
void requestRemoveAllFrameworkItems();
|
||||
|
||||
public:
|
||||
@@ -87,12 +87,12 @@ public:
|
||||
void aboutToShutdown();
|
||||
|
||||
private:
|
||||
bool postponed(const QStringList &fileList);
|
||||
void scanForTests(const QStringList &fileList = QStringList(),
|
||||
bool postponed(const Utils::FilePaths &fileList);
|
||||
void scanForTests(const Utils::FilePaths &fileList = Utils::FilePaths(),
|
||||
const QList<ITestParser *> &parsers = {});
|
||||
|
||||
// qml files must be handled slightly different
|
||||
void onDocumentUpdated(const QString &fileName, bool isQmlFile = false);
|
||||
void onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile = false);
|
||||
void onTaskStarted(Utils::Id type);
|
||||
void onAllTasksFinished(Utils::Id type);
|
||||
void onFinished();
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
bool m_dirty = false;
|
||||
bool m_singleShotScheduled = false;
|
||||
bool m_reparseTimerTimedOut = false;
|
||||
QSet<QString> m_postponedFiles;
|
||||
QSet<Utils::FilePath> m_postponedFiles;
|
||||
State m_parserState = Idle;
|
||||
QFutureWatcher<TestParseResultPtr> m_futureWatcher;
|
||||
QList<ITestParser *> m_testCodeParsers; // ptrs are still owned by TestFrameworkManager
|
||||
|
@@ -62,16 +62,16 @@ void ITestConfiguration::setWorkingDirectory(const QString &workingDirectory)
|
||||
m_runnable.workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
QString ITestConfiguration::workingDirectory() const
|
||||
Utils::FilePath ITestConfiguration::workingDirectory() const
|
||||
{
|
||||
if (!m_runnable.workingDirectory.isEmpty()) {
|
||||
const QFileInfo info(m_runnable.workingDirectory);
|
||||
if (info.isDir()) // ensure wanted working dir does exist
|
||||
return info.absoluteFilePath();
|
||||
return Utils::FilePath::fromString(info.absoluteFilePath());
|
||||
}
|
||||
|
||||
const QString executable = executableFilePath();
|
||||
return executable.isEmpty() ? executable : QFileInfo(executable).absolutePath();
|
||||
const Utils::FilePath executable = executableFilePath();
|
||||
return executable.isEmpty() ? executable : executable.absolutePath();
|
||||
}
|
||||
|
||||
bool ITestConfiguration::hasExecutable() const
|
||||
@@ -79,15 +79,15 @@ bool ITestConfiguration::hasExecutable() const
|
||||
return !m_runnable.executable.isEmpty();
|
||||
}
|
||||
|
||||
QString ITestConfiguration::executableFilePath() const
|
||||
Utils::FilePath ITestConfiguration::executableFilePath() const
|
||||
{
|
||||
if (!hasExecutable())
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
QFileInfo commandFileInfo = m_runnable.executable.toFileInfo();
|
||||
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
|
||||
return commandFileInfo.absoluteFilePath();
|
||||
} else if (commandFileInfo.path() == "."){
|
||||
if (m_runnable.executable.isExecutableFile() && m_runnable.executable.path() != ".") {
|
||||
return m_runnable.executable.absoluteFilePath();
|
||||
} else if (m_runnable.executable.path() == "."){
|
||||
QString fullCommandFileName = m_runnable.executable.toString();
|
||||
// TODO: check if we can use searchInPath() from Utils::Environment
|
||||
const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH")
|
||||
@@ -96,10 +96,10 @@ QString ITestConfiguration::executableFilePath() const
|
||||
for (const QString &path : pathList) {
|
||||
QString filePath(path + QDir::separator() + fullCommandFileName);
|
||||
if (QFileInfo(filePath).isExecutable())
|
||||
return commandFileInfo.absoluteFilePath();
|
||||
return m_runnable.executable.absoluteFilePath();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
Environment ITestConfiguration::filteredEnvironment(const Environment &original) const
|
||||
@@ -158,12 +158,12 @@ void TestConfiguration::completeTestInformation(ProjectExplorer::RunConfiguratio
|
||||
if (!targetInfo.targetFilePath.isEmpty())
|
||||
m_runnable.executable = ensureExeEnding(targetInfo.targetFilePath);
|
||||
|
||||
QString buildBase;
|
||||
Utils::FilePath buildBase;
|
||||
if (auto buildConfig = target->activeBuildConfiguration()) {
|
||||
buildBase = buildConfig->buildDirectory().toString();
|
||||
buildBase = buildConfig->buildDirectory();
|
||||
const QString projBase = startupProject->projectDirectory().toString();
|
||||
if (m_projectFile.startsWith(projBase))
|
||||
m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath();
|
||||
m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath();
|
||||
}
|
||||
if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy)
|
||||
m_runConfig = new Internal::TestRunConfiguration(rc->target(), this);
|
||||
@@ -225,12 +225,12 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
|
||||
if (localExecutable.isEmpty())
|
||||
return;
|
||||
|
||||
QString buildBase;
|
||||
Utils::FilePath buildBase;
|
||||
if (auto buildConfig = target->activeBuildConfiguration()) {
|
||||
buildBase = buildConfig->buildDirectory().toString();
|
||||
buildBase = buildConfig->buildDirectory();
|
||||
const QString projBase = startupProject->projectDirectory().toString();
|
||||
if (m_projectFile.startsWith(projBase))
|
||||
m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath();
|
||||
m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath();
|
||||
}
|
||||
|
||||
// deployment information should get taken into account, but it pretty much seems as if
|
||||
@@ -323,12 +323,12 @@ void TestConfiguration::setExecutableFile(const QString &executableFile)
|
||||
m_runnable.executable = Utils::FilePath::fromString(executableFile);
|
||||
}
|
||||
|
||||
void TestConfiguration::setProjectFile(const QString &projectFile)
|
||||
void TestConfiguration::setProjectFile(const Utils::FilePath &projectFile)
|
||||
{
|
||||
m_projectFile = projectFile;
|
||||
}
|
||||
|
||||
void TestConfiguration::setBuildDirectory(const QString &buildDirectory)
|
||||
void TestConfiguration::setBuildDirectory(const FilePath &buildDirectory)
|
||||
{
|
||||
m_buildDir = buildDirectory;
|
||||
}
|
||||
|
@@ -61,9 +61,9 @@ public:
|
||||
void setEnvironment(const Utils::Environment &env) { m_runnable.environment = env; }
|
||||
Utils::Environment environment() const { return m_runnable.environment; }
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
QString workingDirectory() const;
|
||||
Utils::FilePath workingDirectory() const;
|
||||
bool hasExecutable() const;
|
||||
QString executableFilePath() const;
|
||||
Utils::FilePath executableFilePath() const;
|
||||
|
||||
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const = 0;
|
||||
@@ -99,16 +99,16 @@ public:
|
||||
|
||||
void setTestCases(const QStringList &testCases);
|
||||
void setExecutableFile(const QString &executableFile);
|
||||
void setProjectFile(const QString &projectFile);
|
||||
void setBuildDirectory(const QString &buildDirectory);
|
||||
void setProjectFile(const Utils::FilePath &projectFile);
|
||||
void setBuildDirectory(const Utils::FilePath &buildDirectory);
|
||||
void setInternalTarget(const QString &target);
|
||||
void setInternalTargets(const QSet<QString> &targets);
|
||||
void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
|
||||
|
||||
ITestFramework *framework() const;
|
||||
QStringList testCases() const { return m_testCases; }
|
||||
QString buildDirectory() const { return m_buildDir; }
|
||||
QString projectFile() const { return m_projectFile; }
|
||||
Utils::FilePath buildDirectory() const { return m_buildDir; }
|
||||
Utils::FilePath projectFile() const { return m_projectFile; }
|
||||
QSet<QString> internalTargets() const { return m_buildTargets; }
|
||||
ProjectExplorer::RunConfiguration *originalRunConfiguration() const { return m_origRunConfig; }
|
||||
Internal::TestRunConfiguration *runConfiguration() const { return m_runConfig; }
|
||||
@@ -120,8 +120,8 @@ public:
|
||||
|
||||
private:
|
||||
QStringList m_testCases;
|
||||
QString m_projectFile;
|
||||
QString m_buildDir;
|
||||
Utils::FilePath m_projectFile;
|
||||
Utils::FilePath m_buildDir;
|
||||
QString m_deducedFrom;
|
||||
bool m_deducedConfiguration = false;
|
||||
Internal::TestRunConfiguration *m_runConfig = nullptr;
|
||||
|
@@ -38,8 +38,16 @@
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path,
|
||||
const QString &filePath)
|
||||
{
|
||||
if (!filePath.isEmpty() && filePath.at(0) != '.')
|
||||
return Utils::FilePath::fromFileInfo(QFileInfo(filePath));
|
||||
return (path / filePath).canonicalPath();
|
||||
}
|
||||
|
||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory)
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory)
|
||||
: m_futureInterface(futureInterface)
|
||||
, m_testApplication(testApplication)
|
||||
, m_buildDir(buildDirectory)
|
||||
@@ -167,9 +175,11 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line)
|
||||
m_sanitizerLines.append("Sanitizer Issue");
|
||||
m_sanitizerLines.append(lineStr);
|
||||
if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) {
|
||||
const QString path = QFileInfo(m_buildDir, match.captured(1)).canonicalFilePath();
|
||||
const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1));
|
||||
// path may be empty if not existing - so, provide at least what we have
|
||||
m_sanitizerResult->setFileName(path.isEmpty() ? match.captured(1) : path);
|
||||
m_sanitizerResult->setFileName(path.isEmpty()
|
||||
? Utils::FilePath::fromString(match.captured(1))
|
||||
: path);
|
||||
m_sanitizerResult->setLine(match.captured(2).toInt());
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class TestOutputReader : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QProcess *testApplication, const QString &buildDirectory);
|
||||
QProcess *testApplication, const Utils::FilePath &buildDirectory);
|
||||
virtual ~TestOutputReader();
|
||||
void processStdOutput(const QByteArray &outputLine);
|
||||
virtual void processStdError(const QByteArray &outputLine);
|
||||
@@ -56,6 +56,9 @@ public:
|
||||
signals:
|
||||
void newOutputLineAvailable(const QByteArray &outputLine, OutputChannel channel);
|
||||
protected:
|
||||
static Utils::FilePath constructSourceFilePath(const Utils::FilePath &base,
|
||||
const QString &file);
|
||||
|
||||
QString removeCommandlineColors(const QString &original);
|
||||
virtual void processOutputLine(const QByteArray &outputLine) = 0;
|
||||
virtual TestResultPtr createDefaultResult() const = 0;
|
||||
@@ -65,7 +68,7 @@ protected:
|
||||
void reportResult(const TestResultPtr &result);
|
||||
QFutureInterface<TestResultPtr> m_futureInterface;
|
||||
QProcess *m_testApplication; // not owned
|
||||
QString m_buildDir;
|
||||
Utils::FilePath m_buildDir;
|
||||
QString m_id;
|
||||
QHash<ResultType, int> m_summary;
|
||||
int m_disabled = -1;
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "autotestconstants.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QMetaType>
|
||||
#include <QSharedPointer>
|
||||
@@ -92,11 +94,11 @@ public:
|
||||
QString name() const { return m_name; }
|
||||
ResultType result() const { return m_result; }
|
||||
QString description() const { return m_description; }
|
||||
QString fileName() const { return m_file; }
|
||||
Utils::FilePath fileName() const { return m_file; }
|
||||
int line() const { return m_line; }
|
||||
|
||||
void setDescription(const QString &description) { m_description = description; }
|
||||
void setFileName(const QString &fileName) { m_file = fileName; }
|
||||
void setFileName(const Utils::FilePath &fileName) { m_file = fileName; }
|
||||
void setLine(int line) { m_line = line; }
|
||||
void setResult(ResultType type) { m_result = type; }
|
||||
|
||||
@@ -113,7 +115,7 @@ private:
|
||||
QString m_name;
|
||||
ResultType m_result = ResultType::Invalid; // the real result..
|
||||
QString m_description;
|
||||
QString m_file;
|
||||
Utils::FilePath m_file;
|
||||
int m_line = 0;
|
||||
};
|
||||
|
||||
|
@@ -117,15 +117,10 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
fm.elidedText(output.left(2000), Qt::ElideRight, positions.textAreaWidth()));
|
||||
}
|
||||
|
||||
QString file = testResult->fileName();
|
||||
const int pos = file.lastIndexOf('/');
|
||||
if (pos != -1)
|
||||
file = file.mid(pos + 1);
|
||||
|
||||
const QString file = testResult->fileName().fileName();
|
||||
painter->setClipRect(positions.fileArea());
|
||||
painter->drawText(positions.fileAreaLeft(), positions.top() + fm.ascent(), file);
|
||||
|
||||
|
||||
if (testResult->line()) {
|
||||
QString line = QString::number(testResult->line());
|
||||
painter->setClipRect(positions.lineArea());
|
||||
|
@@ -299,7 +299,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
}
|
||||
|
||||
TestResultItem *parentItem = findParentItemFor(newItem, root);
|
||||
addFileName(testResult->fileName()); // ensure we calculate the results pane correctly
|
||||
addFileName(testResult->fileName().fileName()); // ensure we calculate the results pane correctly
|
||||
if (parentItem) {
|
||||
parentItem->appendChild(newItem);
|
||||
if (autoExpand) {
|
||||
@@ -362,16 +362,14 @@ void TestResultModel::recalculateMaxWidthOfFileName(const QFont &font)
|
||||
const QFontMetrics fm(font);
|
||||
m_maxWidthOfFileName = 0;
|
||||
for (const QString &fileName : qAsConst(m_fileNames)) {
|
||||
int pos = fileName.lastIndexOf('/');
|
||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1)));
|
||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
void TestResultModel::addFileName(const QString &fileName)
|
||||
{
|
||||
const QFontMetrics fm(m_measurementFont);
|
||||
int pos = fileName.lastIndexOf('/');
|
||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1)));
|
||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName));
|
||||
m_fileNames.insert(fileName);
|
||||
}
|
||||
|
||||
|
@@ -473,7 +473,7 @@ void TestResultsPane::onItemActivated(const QModelIndex &index)
|
||||
|
||||
const TestResult *testResult = m_filterModel->testResult(index);
|
||||
if (testResult && !testResult->fileName().isEmpty())
|
||||
EditorManager::openEditorAt(testResult->fileName(), testResult->line(), 0);
|
||||
EditorManager::openEditorAt(Utils::Link{testResult->fileName(), testResult->line(), 0});
|
||||
}
|
||||
|
||||
void TestResultsPane::onRunAllTriggered()
|
||||
@@ -750,8 +750,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent)
|
||||
bool isLocationItem = result->result() == ResultType::MessageLocation;
|
||||
if (interested.contains(result->result())
|
||||
|| (isLocationItem && interested.contains(parentType))) {
|
||||
const Utils::FilePath fileName = Utils::FilePath::fromString(result->fileName());
|
||||
TestEditorMark *mark = new TestEditorMark(index, fileName, result->line());
|
||||
TestEditorMark *mark = new TestEditorMark(index, result->fileName(), result->line());
|
||||
mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
|
||||
mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor);
|
||||
mark->setPriority(TextEditor::TextMark::NormalPriority);
|
||||
|
@@ -65,9 +65,9 @@ public:
|
||||
{
|
||||
ProjectExplorer::Runnable r;
|
||||
QTC_ASSERT(m_testConfig, return r);
|
||||
r.executable = Utils::FilePath::fromString(m_testConfig->executableFilePath());
|
||||
r.executable = m_testConfig->executableFilePath();
|
||||
r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' ');
|
||||
r.workingDirectory = m_testConfig->workingDirectory();
|
||||
r.workingDirectory = m_testConfig->workingDirectory().toString();
|
||||
r.environment = m_testConfig->environment();
|
||||
r.device = ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
||||
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
|
@@ -176,13 +176,13 @@ static QString constructOmittedVariablesDetailsString(const Utils::EnvironmentIt
|
||||
|
||||
bool TestRunner::currentConfigValid()
|
||||
{
|
||||
QString commandFilePath;
|
||||
Utils::FilePath commandFilePath;
|
||||
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
|
||||
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
|
||||
commandFilePath = current->executableFilePath();
|
||||
} else {
|
||||
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(m_currentConfig);
|
||||
commandFilePath = current->commandLine().executable().toString();
|
||||
commandFilePath = current->commandLine().executable();
|
||||
}
|
||||
if (commandFilePath.isEmpty()) {
|
||||
reportResult(ResultType::MessageFatal,
|
||||
@@ -208,7 +208,7 @@ void TestRunner::setUpProcess()
|
||||
m_currentProcess->setReadChannel(QProcess::StandardOutput);
|
||||
if (m_currentConfig->testBase()->type() == ITestBase::Framework) {
|
||||
TestConfiguration *current = static_cast<TestConfiguration *>(m_currentConfig);
|
||||
m_currentProcess->setProgram(current->executableFilePath());
|
||||
m_currentProcess->setProgram(current->executableFilePath().toString());
|
||||
} else {
|
||||
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(m_currentConfig);
|
||||
m_currentProcess->setProgram(current->commandLine().executable().toString());
|
||||
@@ -231,7 +231,7 @@ void TestRunner::setUpProcessEnv()
|
||||
m_currentProcess->setArguments(current->commandLine().splitArguments());
|
||||
}
|
||||
|
||||
m_currentProcess->setWorkingDirectory(m_currentConfig->workingDirectory());
|
||||
m_currentProcess->setWorkingDirectory(m_currentConfig->workingDirectory().toString());
|
||||
const Utils::Environment &original = m_currentConfig->environment();
|
||||
Utils::Environment environment = m_currentConfig->filteredEnvironment(original);
|
||||
const Utils::EnvironmentItems removedVariables = Utils::filtered(
|
||||
@@ -625,10 +625,10 @@ void TestRunner::debugTests()
|
||||
return;
|
||||
}
|
||||
|
||||
const QString &commandFilePath = config->executableFilePath();
|
||||
const Utils::FilePath &commandFilePath = config->executableFilePath();
|
||||
if (commandFilePath.isEmpty()) {
|
||||
reportResult(ResultType::MessageFatal, tr("Could not find command \"%1\". (%2)")
|
||||
.arg(config->executableFilePath(), config->displayName()));
|
||||
.arg(config->executableFilePath().toString(), config->displayName()));
|
||||
onFinished();
|
||||
return;
|
||||
}
|
||||
@@ -638,7 +638,7 @@ void TestRunner::debugTests()
|
||||
|
||||
QStringList omitted;
|
||||
Runnable inferior = config->runnable();
|
||||
inferior.executable = FilePath::fromString(commandFilePath);
|
||||
inferior.executable = commandFilePath;
|
||||
|
||||
const QStringList args = config->argumentsForTestRunner(&omitted);
|
||||
inferior.commandLineArguments = Utils::ProcessArgs::joinArgs(args);
|
||||
|
@@ -54,7 +54,7 @@ static QIcon testTreeIcon(TestTreeItem::Type type)
|
||||
}
|
||||
|
||||
ITestTreeItem::ITestTreeItem(ITestBase *testBase, const QString &name,
|
||||
const QString &filePath, Type type)
|
||||
const Utils::FilePath &filePath, Type type)
|
||||
: m_testBase(testBase)
|
||||
, m_name(name)
|
||||
, m_filePath(filePath)
|
||||
@@ -70,7 +70,7 @@ QVariant ITestTreeItem::data(int /*column*/, int role) const
|
||||
else
|
||||
return m_name;
|
||||
case Qt::ToolTipRole:
|
||||
return m_filePath;
|
||||
return m_filePath.toString();
|
||||
case Qt::DecorationRole:
|
||||
return testTreeIcon(m_type);
|
||||
case Qt::CheckStateRole:
|
||||
@@ -162,7 +162,7 @@ ITestConfiguration *ITestTreeItem::asConfiguration(TestRunMode mode) const
|
||||
/****************************** TestTreeItem ********************************************/
|
||||
|
||||
TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name,
|
||||
const QString &filePath, Type type)
|
||||
const Utils::FilePath &filePath, Type type)
|
||||
: ITestTreeItem(testFramework, name, filePath, type)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -186,7 +186,7 @@ QVariant TestTreeItem::data(int column, int role) const
|
||||
return QVariant();
|
||||
QVariant itemLink;
|
||||
itemLink.setValue(
|
||||
Utils::Link(Utils::FilePath::fromString(filePath()), line(), int(m_column)));
|
||||
Utils::Link(filePath(), line(), int(m_column)));
|
||||
return itemLink;
|
||||
}
|
||||
return ITestTreeItem::data(column, role);
|
||||
@@ -240,7 +240,7 @@ void TestTreeItem::markForRemovalRecursively(bool mark)
|
||||
childItem(row)->markForRemovalRecursively(mark);
|
||||
}
|
||||
|
||||
void TestTreeItem::markForRemovalRecursively(const QString &filepath)
|
||||
void TestTreeItem::markForRemovalRecursively(const Utils::FilePath &filepath)
|
||||
{
|
||||
bool mark = filePath() == filepath;
|
||||
forFirstLevelChildItems([&mark, &filepath](TestTreeItem *child) {
|
||||
@@ -267,20 +267,20 @@ TestTreeItem *TestTreeItem::findChildByName(const QString &name)
|
||||
});
|
||||
}
|
||||
|
||||
TestTreeItem *TestTreeItem::findChildByFile(const QString &filePath)
|
||||
TestTreeItem *TestTreeItem::findChildByFile(const Utils::FilePath &filePath)
|
||||
{
|
||||
return findFirstLevelChildItem([filePath](const TestTreeItem *other) {
|
||||
return other->filePath() == filePath;
|
||||
});
|
||||
}
|
||||
|
||||
TestTreeItem *TestTreeItem::findChildByFileAndType(const QString &filePath, Type tType)
|
||||
TestTreeItem *TestTreeItem::findChildByFileAndType(const Utils::FilePath &filePath, Type tType)
|
||||
{
|
||||
return findFirstLevelChildItem([filePath, tType](const TestTreeItem *other) {
|
||||
return other->type() == tType && other->filePath() == filePath;
|
||||
});}
|
||||
|
||||
TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const QString &filePath)
|
||||
TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath)
|
||||
{
|
||||
return findFirstLevelChildItem([name, filePath](const TestTreeItem *other) {
|
||||
return other->filePath() == filePath && other->name() == name;
|
||||
@@ -310,7 +310,7 @@ bool TestTreeItem::isGroupNodeFor(const TestTreeItem *other) const
|
||||
return false;
|
||||
|
||||
// for now there's only the possibility to have 'Folder' nodes
|
||||
return QFileInfo(other->filePath()).absolutePath() == filePath();
|
||||
return other->filePath().absolutePath() == filePath();
|
||||
}
|
||||
|
||||
bool TestTreeItem::isGroupable() const
|
||||
@@ -360,7 +360,7 @@ void TestTreeItem::copyBasicDataFrom(const TestTreeItem *other)
|
||||
m_status = other->m_status;
|
||||
}
|
||||
|
||||
inline bool TestTreeItem::modifyFilePath(const QString &filepath)
|
||||
inline bool TestTreeItem::modifyFilePath(const Utils::FilePath &filepath)
|
||||
{
|
||||
if (filePath() != filepath) {
|
||||
setFilePath(filepath);
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <QList>
|
||||
@@ -42,8 +43,6 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
class ITestBase;
|
||||
@@ -75,7 +74,7 @@ public:
|
||||
|
||||
explicit ITestTreeItem(ITestBase *testBase,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root);
|
||||
|
||||
virtual QVariant data(int column, int role) const override;
|
||||
@@ -93,15 +92,15 @@ public:
|
||||
|
||||
const QString name() const { return m_name; }
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
const QString filePath() const { return m_filePath; }
|
||||
void setFilePath(const QString &filePath) { m_filePath = filePath; }
|
||||
const Utils::FilePath filePath() const { return m_filePath; }
|
||||
void setFilePath(const Utils::FilePath &filePath) { m_filePath = filePath; }
|
||||
Type type() const { return m_type; }
|
||||
int line() const { return m_line; }
|
||||
void setLine(int line) { m_line = line;}
|
||||
ITestBase *testBase() const { return m_testBase; }
|
||||
|
||||
virtual bool lessThan(const ITestTreeItem *other, SortMode mode) const;
|
||||
QString cacheName() const { return m_filePath + ':' + m_name; }
|
||||
QString cacheName() const { return m_filePath.toString() + ':' + m_name; }
|
||||
|
||||
protected:
|
||||
void setType(Type type) { m_type = type; }
|
||||
@@ -110,7 +109,7 @@ protected:
|
||||
private:
|
||||
ITestBase *m_testBase = nullptr; // not owned
|
||||
QString m_name;
|
||||
QString m_filePath;
|
||||
Utils::FilePath m_filePath;
|
||||
Type m_type;
|
||||
int m_line = 0;
|
||||
bool m_failed = false;
|
||||
@@ -121,7 +120,7 @@ class TestTreeItem : public ITestTreeItem
|
||||
public:
|
||||
explicit TestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const QString &filePath = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root);
|
||||
|
||||
virtual TestTreeItem *copyWithoutChildren() = 0;
|
||||
@@ -134,11 +133,11 @@ public:
|
||||
ITestFramework *framework() const;
|
||||
void setColumn(int column) { m_column = column; }
|
||||
int column() const { return m_column; }
|
||||
QString proFile() const { return m_proFile; }
|
||||
void setProFile(const QString &proFile) { m_proFile = proFile; }
|
||||
Utils::FilePath proFile() const { return m_proFile; }
|
||||
void setProFile(const Utils::FilePath &proFile) { m_proFile = proFile; }
|
||||
void markForRemoval(bool mark);
|
||||
void markForRemovalRecursively(bool mark);
|
||||
virtual void markForRemovalRecursively(const QString &filepath);
|
||||
virtual void markForRemovalRecursively(const Utils::FilePath &filepath);
|
||||
virtual bool removeOnSweepIfEmpty() const { return type() == GroupNode; }
|
||||
bool markedForRemoval() const { return m_status == MarkedForRemoval; }
|
||||
bool newlyAdded() const { return m_status == NewlyAdded; }
|
||||
@@ -146,9 +145,9 @@ public:
|
||||
TestTreeItem *parentItem() const;
|
||||
|
||||
TestTreeItem *findChildByName(const QString &name);
|
||||
TestTreeItem *findChildByFile(const QString &filePath);
|
||||
TestTreeItem *findChildByFileAndType(const QString &filePath, Type type);
|
||||
TestTreeItem *findChildByNameAndFile(const QString &name, const QString &filePath);
|
||||
TestTreeItem *findChildByFile(const Utils::FilePath &filePath);
|
||||
TestTreeItem *findChildByFileAndType(const Utils::FilePath &filePath, Type type);
|
||||
TestTreeItem *findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath);
|
||||
|
||||
virtual ITestConfiguration *debugConfiguration() const { return nullptr; }
|
||||
virtual bool canProvideDebugConfiguration() const { return false; }
|
||||
@@ -174,7 +173,7 @@ protected:
|
||||
typedef std::function<bool(const TestTreeItem *)> CompareFunction;
|
||||
|
||||
private:
|
||||
bool modifyFilePath(const QString &filepath);
|
||||
bool modifyFilePath(const Utils::FilePath &filepath);
|
||||
bool modifyName(const QString &name);
|
||||
|
||||
enum Status
|
||||
@@ -185,7 +184,7 @@ private:
|
||||
};
|
||||
|
||||
int m_column = 0;
|
||||
QString m_proFile;
|
||||
Utils::FilePath m_proFile;
|
||||
Status m_status = NewlyAdded;
|
||||
|
||||
friend class TestTreeModel; // grant access to (protected) findChildBy()
|
||||
@@ -194,7 +193,7 @@ private:
|
||||
class TestCodeLocationAndType
|
||||
{
|
||||
public:
|
||||
QString m_name; // tag name for m_type == TestDataTag, file name for other values
|
||||
QString m_name; // tag name for m_type == TestDataTag, file name for other values // FIXME
|
||||
int m_line = 0;
|
||||
int m_column = 0;
|
||||
TestTreeItem::Type m_type = TestTreeItem::Root;
|
||||
|
@@ -115,7 +115,11 @@ void TestTreeModel::setupParsingConnections()
|
||||
connect(cppMM, &CppTools::CppModelManager::documentUpdated,
|
||||
m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection);
|
||||
connect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles,
|
||||
this, &TestTreeModel::removeFiles, Qt::QueuedConnection);
|
||||
this, [this](const QStringList &files) {
|
||||
const Utils::FilePaths filesToRemove
|
||||
= Utils::transform(files, &Utils::FilePath::fromString);
|
||||
removeFiles(filesToRemove);
|
||||
}, Qt::QueuedConnection);
|
||||
connect(cppMM, &CppTools::CppModelManager::projectPartsUpdated,
|
||||
m_parser, &TestCodeParser::onProjectPartsUpdated);
|
||||
|
||||
@@ -123,7 +127,11 @@ void TestTreeModel::setupParsingConnections()
|
||||
connect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated,
|
||||
m_parser, &TestCodeParser::onQmlDocumentUpdated, Qt::QueuedConnection);
|
||||
connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
|
||||
this, &TestTreeModel::removeFiles, Qt::QueuedConnection);
|
||||
this, [this](const QStringList files) {
|
||||
const Utils::FilePaths filesToRemove
|
||||
= Utils::transform(files, &Utils::FilePath::fromString);
|
||||
removeFiles(filesToRemove);
|
||||
}, Qt::QueuedConnection);
|
||||
connectionsInitialized = true;
|
||||
}
|
||||
|
||||
@@ -481,9 +489,9 @@ void TestTreeModel::clearFailedMarks()
|
||||
m_failedStateCache.clear();
|
||||
}
|
||||
|
||||
void TestTreeModel::removeFiles(const QStringList &files)
|
||||
void TestTreeModel::removeFiles(const Utils::FilePaths &files)
|
||||
{
|
||||
for (const QString &file : files)
|
||||
for (const Utils::FilePath &file : files)
|
||||
markForRemoval(file);
|
||||
sweep();
|
||||
}
|
||||
@@ -497,7 +505,7 @@ void TestTreeModel::markAllFrameworkItemsForRemoval()
|
||||
}
|
||||
}
|
||||
|
||||
void TestTreeModel::markForRemoval(const QString &filePath)
|
||||
void TestTreeModel::markForRemoval(const Utils::FilePath &filePath)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
@@ -865,7 +873,7 @@ QMap<QString, int> TestTreeModel::boostTestSuitesAndTests() const
|
||||
|
||||
if (TestTreeItem *rootNode = boostTestRootNode()) {
|
||||
rootNode->forFirstLevelChildItems([&result](TestTreeItem *child) {
|
||||
result.insert(child->name() + '|' + child->proFile(), child->childCount());
|
||||
result.insert(child->name() + '|' + child->proFile().toString(), child->childCount());
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
#endif
|
||||
|
||||
void markAllFrameworkItemsForRemoval();
|
||||
void markForRemoval(const QString &filePath);
|
||||
void markForRemoval(const Utils::FilePath &filePath);
|
||||
void sweep();
|
||||
|
||||
signals:
|
||||
@@ -105,7 +105,7 @@ private:
|
||||
void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode);
|
||||
void removeAllTestItems();
|
||||
void removeAllTestToolItems();
|
||||
void removeFiles(const QStringList &files);
|
||||
void removeFiles(const Utils::FilePaths &files);
|
||||
bool sweepChildren(TestTreeItem *item);
|
||||
void insertItemInParent(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled);
|
||||
void revalidateCheckState(ITestTreeItem *item);
|
||||
|
@@ -1419,16 +1419,16 @@ void CppModelManager::onAboutToLoadSession()
|
||||
GC();
|
||||
}
|
||||
|
||||
QSet<QString> CppModelManager::dependingInternalTargets(const QString &file) const
|
||||
QSet<QString> CppModelManager::dependingInternalTargets(const Utils::FilePath &file) const
|
||||
{
|
||||
QSet<QString> result;
|
||||
const Snapshot snapshot = this->snapshot();
|
||||
QTC_ASSERT(snapshot.contains(file), return result);
|
||||
bool wasHeader;
|
||||
const QString correspondingFile
|
||||
= correspondingHeaderOrSource(file, &wasHeader, CacheUsage::ReadOnly);
|
||||
= correspondingHeaderOrSource(file.toString(), &wasHeader, CacheUsage::ReadOnly);
|
||||
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
|
||||
wasHeader ? file : correspondingFile);
|
||||
wasHeader ? file : Utils::FilePath::fromString(correspondingFile));
|
||||
for (const Utils::FilePath &fn : qAsConst(dependingFiles)) {
|
||||
for (const ProjectPart::Ptr &part : projectPart(fn))
|
||||
result.insert(part->buildSystemTarget);
|
||||
@@ -1436,7 +1436,7 @@ QSet<QString> CppModelManager::dependingInternalTargets(const QString &file) con
|
||||
return result;
|
||||
}
|
||||
|
||||
QSet<QString> CppModelManager::internalTargets(const QString &filePath) const
|
||||
QSet<QString> CppModelManager::internalTargets(const Utils::FilePath &filePath) const
|
||||
{
|
||||
const QList<ProjectPart::Ptr> projectParts = projectPart(filePath);
|
||||
// if we have no project parts it's most likely a header with declarations only and CMake based
|
||||
|
@@ -237,9 +237,9 @@ public:
|
||||
* 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
|
||||
*/
|
||||
QSet<QString> dependingInternalTargets(const QString &file) const;
|
||||
QSet<QString> dependingInternalTargets(const Utils::FilePath &file) const;
|
||||
|
||||
QSet<QString> internalTargets(const QString &filePath) const;
|
||||
QSet<QString> internalTargets(const Utils::FilePath &filePath) const;
|
||||
|
||||
void renameIncludes(const QString &oldFileName, const QString &newFileName);
|
||||
|
||||
|
Reference in New Issue
Block a user