CppEditor/CppTools: Tests: Fix potential race condition

...when updating the code model.

Change-Id: Ifc55b7d0bb795b9cfd72465990991bc2cc907846
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-12-11 14:10:09 +01:00
committed by Erik Verbruggen
parent dad0140134
commit 9b41023b68
10 changed files with 67 additions and 90 deletions

View File

@@ -209,20 +209,12 @@ void TestCase::init(const QStringList &includePaths)
QStringList filePaths;
foreach (const TestDocumentPtr &testFile, testFiles)
filePaths << testFile->filePath();
cmm->updateSourceFiles(filePaths);
// Wait for the parser in the future to give us the document
QStringList filePathsNotYetInSnapshot(filePaths);
forever {
Snapshot snapshot = cmm->snapshot();
foreach (const QString &filePath, filePathsNotYetInSnapshot) {
if (snapshot.contains(filePath))
filePathsNotYetInSnapshot.removeOne(filePath);
}
if (filePathsNotYetInSnapshot.isEmpty())
break;
QCoreApplication::processEvents();
}
cmm->updateSourceFiles(filePaths).waitForFinished();
QCoreApplication::processEvents();
const Snapshot snapshot = cmm->snapshot();
QVERIFY(!snapshot.isEmpty());
foreach (const QString &filePath, filePaths)
QVERIFY(snapshot.contains(filePath));
// Open Files
foreach (TestDocumentPtr testFile, testFiles) {