summaryrefslogtreecommitdiff
path: root/src/plugins/autotest/quick/quicktestparser.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-07-10 14:47:40 +0200
committerChristian Stenger <christian.stenger@qt.io>2018-07-11 13:18:04 +0000
commitf80aa2c6f7b85de4bbe050fb96bd6852908f3e58 (patch)
treed0b0a274725433779f8cb0cb2fa354f8a21ac0f4 /src/plugins/autotest/quick/quicktestparser.cpp
parentf18d2ded9b6febef0d9c47b03e1a00f4fc526ddc (diff)
downloadqt-creator-f80aa2c6f7b85de4bbe050fb96bd6852908f3e58.tar.gz
AutoTest: Fix handling of cpp files for Quick tests
Modifying C++ files of Quick tests had been ignored as they normally have little impact. But nevertheless this behavior is wrong and could lead to unexpected behavior later on if no complete rescan had been done and even with a rescan there could have been some cached artifacts. Fix this by tracking the paths of the C++ files that hold the main() or the respective macro to be able to handle changes of these files correctly as well. Task-number: QTCREATORBUG-20746 Change-Id: Iec860aa63ffd167511efdbf63a6ffa369f094edf Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest/quick/quicktestparser.cpp')
-rw-r--r--src/plugins/autotest/quick/quicktestparser.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp
index 73e6ed3080..91c1bfb36e 100644
--- a/src/plugins/autotest/quick/quicktestparser.cpp
+++ b/src/plugins/autotest/quick/quicktestparser.cpp
@@ -212,7 +212,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterface,
CPlusPlus::Document::Ptr document,
- const Core::Id &id) const
+ const Core::Id &id)
{
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
if (quickTestName(document).isEmpty())
@@ -223,7 +223,7 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> fut
if (ppList.isEmpty()) // happens if shutting down while parsing
return false;
const QString &proFile = ppList.at(0)->projectFile;
-
+ m_mainCppFiles.insert(cppFileName, proFile);
const QString srcDir = quickTestSrcDir(modelManager, cppFileName);
if (srcDir.isEmpty())
return false;
@@ -306,8 +306,21 @@ QuickTestParser::~QuickTestParser()
void QuickTestParser::init(const QStringList &filesToParse, bool fullParse)
{
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
- if (!fullParse) // in a full parse we get the correct entry points by the respective main
+ if (!fullParse) {
+ // in a full parse we get the correct entry points by the respective main
m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(id(), filesToParse);
+ // get rid of cached main cpp files that are going to get processed anyhow
+ for (const QString &file : filesToParse) {
+ if (m_mainCppFiles.contains(file)) {
+ m_mainCppFiles.remove(file);
+ if (m_mainCppFiles.isEmpty())
+ break;
+ }
+ }
+ } else {
+ // get rid of all cached main cpp files
+ m_mainCppFiles.clear();
+ }
CppParser::init(filesToParse, fullParse);
}
@@ -336,5 +349,10 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
return handleQtQuickTest(futureInterface, document, id());
}
+QString QuickTestParser::projectFileForMainCppFile(const QString &fileName) const
+{
+ return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : QString();
+}
+
} // namespace Internal
} // namespace Autotest