forked from qt-creator/qt-creator
CppTools: Tests: time out in waitForFileInGlobalSnapshot()
Change-Id: I0bf7d826d53749c5fd1be1e4f3c2faa403d13342 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -295,6 +295,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
|||||||
// that is the function bodies are processed.
|
// that is the function bodies are processed.
|
||||||
forever {
|
forever {
|
||||||
const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
|
const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
|
||||||
|
QVERIFY(document);
|
||||||
if (document->checkMode() == Document::FullCheck) {
|
if (document->checkMode() == Document::FullCheck) {
|
||||||
QVERIFY(document->diagnosticMessages().isEmpty());
|
QVERIFY(document->diagnosticMessages().isEmpty());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -88,8 +88,7 @@ public:
|
|||||||
m_textDocument = m_editorWidget->document();
|
m_textDocument = m_editorWidget->document();
|
||||||
|
|
||||||
// Get Document
|
// Get Document
|
||||||
waitForFileInGlobalSnapshot(fileName);
|
const Document::Ptr document = waitForFileInGlobalSnapshot(fileName);
|
||||||
const Document::Ptr document = globalSnapshot().document(fileName);
|
|
||||||
QVERIFY(document);
|
QVERIFY(document);
|
||||||
QVERIFY(document->diagnosticMessages().isEmpty());
|
QVERIFY(document->diagnosticMessages().isEmpty());
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ private:
|
|||||||
m_editor = EditorManager::openEditor(m_fileName);
|
m_editor = EditorManager::openEditor(m_fileName);
|
||||||
QVERIFY(m_editor);
|
QVERIFY(m_editor);
|
||||||
|
|
||||||
waitForFileInGlobalSnapshot(m_fileName);
|
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAfterLocatorRun()
|
void doAfterLocatorRun()
|
||||||
|
|||||||
@@ -170,14 +170,19 @@ bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *edito
|
|||||||
return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor);
|
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(
|
QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QStringList &filePaths,
|
||||||
const QStringList &filePaths)
|
int timeOutInMs)
|
||||||
{
|
{
|
||||||
|
QTime t;
|
||||||
|
t.start();
|
||||||
|
|
||||||
QList<CPlusPlus::Document::Ptr> result;
|
QList<CPlusPlus::Document::Ptr> result;
|
||||||
foreach (const QString &filePath, filePaths) {
|
foreach (const QString &filePath, filePaths) {
|
||||||
forever {
|
forever {
|
||||||
@@ -185,13 +190,15 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(
|
|||||||
result.append(document);
|
result.append(document);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (t.elapsed() > timeOutInMs)
|
||||||
|
return QList<CPlusPlus::Document::Ptr>();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut)
|
bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOutInMs)
|
||||||
{
|
{
|
||||||
if (!project)
|
if (!project)
|
||||||
return false;
|
return false;
|
||||||
@@ -203,7 +210,7 @@ bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut)
|
|||||||
forever {
|
forever {
|
||||||
if (modelManager->projectInfo(project).isValid())
|
if (modelManager->projectInfo(project).isValid())
|
||||||
return true;
|
return true;
|
||||||
if (t.elapsed() > timeOut)
|
if (t.elapsed() > timeOutInMs)
|
||||||
return false;
|
return false;
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,11 +93,16 @@ public:
|
|||||||
static CPlusPlus::Snapshot globalSnapshot();
|
static CPlusPlus::Snapshot globalSnapshot();
|
||||||
static bool garbageCollectGlobalSnapshot();
|
static bool garbageCollectGlobalSnapshot();
|
||||||
|
|
||||||
static bool waitUntilCppModelManagerIsAwareOf(ProjectExplorer::Project *project,
|
enum { defaultTimeOutInMs = 30 * 1000 /*= 30 secs*/ };
|
||||||
int timeOut = 30 * 1000 /*= 30 secs*/);
|
static bool waitUntilCppModelManagerIsAwareOf(
|
||||||
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(const QString &filePath);
|
ProjectExplorer::Project *project,
|
||||||
|
int timeOutInMs = defaultTimeOutInMs);
|
||||||
|
static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(
|
||||||
|
const QString &filePath,
|
||||||
|
int timeOutInMs = defaultTimeOutInMs);
|
||||||
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
|
static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
|
||||||
const QStringList &filePaths);
|
const QStringList &filePaths,
|
||||||
|
int timeOutInMs = defaultTimeOutInMs);
|
||||||
|
|
||||||
static bool writeFile(const QString &filePath, const QByteArray &contents);
|
static bool writeFile(const QString &filePath, const QByteArray &contents);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user