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