Commit 93c8509a authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Tests: time out in waitForFileInGlobalSnapshot()

Change-Id: I0bf7d826d53749c5fd1be1e4f3c2faa403d13342
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 1e0b7e52
......@@ -295,6 +295,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
// that is the function bodies are processed.
forever {
const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
QVERIFY(document);
if (document->checkMode() == Document::FullCheck) {
QVERIFY(document->diagnosticMessages().isEmpty());
break;
......
......@@ -88,8 +88,7 @@ public:
m_textDocument = m_editorWidget->document();
// Get Document
waitForFileInGlobalSnapshot(fileName);
const Document::Ptr document = globalSnapshot().document(fileName);
const Document::Ptr document = waitForFileInGlobalSnapshot(fileName);
QVERIFY(document);
QVERIFY(document->diagnosticMessages().isEmpty());
......
......@@ -128,7 +128,7 @@ private:
m_editor = EditorManager::openEditor(m_fileName);
QVERIFY(m_editor);
waitForFileInGlobalSnapshot(m_fileName);
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
}
void doAfterLocatorRun()
......
......@@ -170,14 +170,19 @@ bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *edito
return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor);
}
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath)
CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath,
int timeOutInMs)
{
return waitForFilesInGlobalSnapshot(QStringList(filePath)).first();
const auto documents = waitForFilesInGlobalSnapshot(QStringList(filePath), timeOutInMs);
return documents.isEmpty() ? CPlusPlus::Document::Ptr() : documents.first();
}
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(
const QStringList &filePaths)
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QStringList &filePaths,
int timeOutInMs)
{
QTime t;
t.start();
QList<CPlusPlus::Document::Ptr> result;
foreach (const QString &filePath, filePaths) {
forever {
......@@ -185,13 +190,15 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(
result.append(document);
break;
}
if (t.elapsed() > timeOutInMs)
return QList<CPlusPlus::Document::Ptr>();
QCoreApplication::processEvents();
}
}
return result;
}
bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut)
bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOutInMs)
{
if (!project)
return false;
......@@ -203,7 +210,7 @@ bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut)
forever {
if (modelManager->projectInfo(project).isValid())
return true;
if (t.elapsed() > timeOut)
if (t.elapsed() > timeOutInMs)
return false;
QCoreApplication::processEvents();
}
......
......@@ -93,11 +93,16 @@ public:
static CPlusPlus::Snapshot globalSnapshot();
static bool garbageCollectGlobalSnapshot();
static bool waitUntilCppModelManagerIsAwareOf(ProjectExplorer::Project *project,
int timeOut = 30 * 1000 /*= 30 secs*/);
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(const QString &filePath);
enum { defaultTimeOutInMs = 30 * 1000 /*= 30 secs*/ };
static bool waitUntilCppModelManagerIsAwareOf(
ProjectExplorer::Project *project,
int timeOutInMs = defaultTimeOutInMs);
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(
const QString &filePath,
int timeOutInMs = defaultTimeOutInMs);
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
const QStringList &filePaths);
const QStringList &filePaths,
int timeOutInMs = defaultTimeOutInMs);
static bool writeFile(const QString &filePath, const QByteArray &contents);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment