AutoTest: Fix parsing for QuickTests

If the scan for quick tests was triggered just by a change of a
qml file (including indexing by the respective modelmanager) we
might find tests that won't be able to execute.
If we have already found quick tests we know their respective
project files. If we cannot find the files to be scanned inside the
already found ignore scan requests for such files.

This patch is kind of a continuation of b570ee1b80
(Fix initial parsing when loading session)

Change-Id: Ic1228641f60abf127134acbd4232a0ddd30ef159
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Stenger
2016-07-12 09:45:55 +02:00
parent e51443ce62
commit 0b527de52e
3 changed files with 40 additions and 1 deletions

View File

@@ -25,6 +25,10 @@
#pragma once
#include "../testframeworkmanager.h"
#include <utils/qtcassert.h>
#include <QByteArrayList>
namespace Autotest {
@@ -38,6 +42,36 @@ public:
static const QByteArrayList valid = {"QUICK_TEST_MAIN", "QUICK_TEST_OPENGL_MAIN"};
return valid.contains(macro);
}
static QHash<QString, QString> proFilesForQmlFiles(const Core::Id &id, const QStringList &files)
{
QHash<QString, QString> result;
TestTreeItem *rootNode = TestFrameworkManager::instance()->rootNodeForTestFramework(id);
QTC_ASSERT(rootNode, return result);
if (files.isEmpty())
return result;
for (int row = 0, rootCount = rootNode->childCount(); row < rootCount; ++row) {
const TestTreeItem *child = rootNode->childItem(row);
const QString &file = child->filePath();
if (!file.isEmpty() && files.contains(file)) {
const QString &proFile = child->proFile();
if (!proFile.isEmpty())
result.insert(file, proFile);
}
for (int subRow = 0, subCount = child->childCount(); subRow < subCount; ++subRow) {
const TestTreeItem *grandChild = child->childItem(subRow);
const QString &file = grandChild->filePath();
if (!file.isEmpty() && files.contains(file)) {
const QString &proFile = grandChild->proFile();
if (!proFile.isEmpty())
result.insert(file, proFile);
}
}
}
return result;
}
};
} // namespace Internal

View File

@@ -220,6 +220,7 @@ static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterfa
void QuickTestParser::init(const QStringList &filesToParse)
{
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(id(), filesToParse);
CppParser::init(filesToParse);
}
@@ -227,8 +228,11 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
const QString &fileName)
{
if (fileName.endsWith(".qml")) {
const QString &proFile = m_proFilesForQmlFiles.value(fileName);
if (proFile.isEmpty())
return false;
QmlJS::Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName);
return checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id());
return checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id(), proFile);
}
if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName))
return false;

View File

@@ -47,6 +47,7 @@ public:
const QString &fileName) override;
private:
QmlJS::Snapshot m_qmlSnapshot;
QHash<QString, QString> m_proFilesForQmlFiles;
};
} // namespace Internal