Skip to content
Snippets Groups Projects
Commit a4b74730 authored by Christian Stenger's avatar Christian Stenger
Browse files

AutoTest: Fix flaky unit test


Since parsing and updating the tree model has been changed the
respective tests became flaky.

Change-Id: I82fcde51493bc86e2315018b21e9bacd8e8409a9
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 25d63d85
No related branches found
No related tags found
No related merge requests found
...@@ -96,7 +96,9 @@ void AutoTestUnitTests::testCodeParser() ...@@ -96,7 +96,9 @@ void AutoTestUnitTests::testCodeParser()
QVERIFY(projectInfo.isValid()); QVERIFY(projectInfo.isValid());
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
QVERIFY(parserSpy.wait(20000)); QVERIFY(parserSpy.wait(20000));
QVERIFY(modelUpdateSpy.wait());
if (m_isQt4) if (m_isQt4)
expectedNamedQuickTestsCount = expectedUnnamedQuickTestsCount = 0; expectedNamedQuickTestsCount = expectedUnnamedQuickTestsCount = 0;
...@@ -148,7 +150,9 @@ void AutoTestUnitTests::testCodeParserSwitchStartup() ...@@ -148,7 +150,9 @@ void AutoTestUnitTests::testCodeParserSwitchStartup()
QVERIFY(projectInfo.isValid()); QVERIFY(projectInfo.isValid());
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
QVERIFY(parserSpy.wait(20000)); QVERIFY(parserSpy.wait(20000));
QVERIFY(modelUpdateSpy.wait());
QCOMPARE(m_model->autoTestsCount(), expectedAutoTestsCount.at(i)); QCOMPARE(m_model->autoTestsCount(), expectedAutoTestsCount.at(i));
QCOMPARE(m_model->namedQuickTestsCount(), QCOMPARE(m_model->namedQuickTestsCount(),
...@@ -198,7 +202,9 @@ void AutoTestUnitTests::testCodeParserGTest() ...@@ -198,7 +202,9 @@ void AutoTestUnitTests::testCodeParserGTest()
QVERIFY(projectInfo.isValid()); QVERIFY(projectInfo.isValid());
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
QVERIFY(parserSpy.wait(20000)); QVERIFY(parserSpy.wait(20000));
QVERIFY(modelUpdateSpy.wait());
QCOMPARE(m_model->gtestNamesCount(), 6); QCOMPARE(m_model->gtestNamesCount(), 6);
......
...@@ -63,6 +63,10 @@ public: ...@@ -63,6 +63,10 @@ public:
void setState(State state); void setState(State state);
State state() const { return m_parserState; } State state() const { return m_parserState; }
void setDirty() { m_dirty = true; } void setDirty() { m_dirty = true; }
#ifdef WITH_TESTS
bool furtherParsingExpected() const
{ return m_singleShotScheduled || m_fullUpdatePostponed || m_partialUpdatePostponed; }
#endif
signals: signals:
void aboutToPerformFullParse(); void aboutToPerformFullParse();
......
...@@ -569,6 +569,10 @@ void TestTreeModel::sweep() ...@@ -569,6 +569,10 @@ void TestTreeModel::sweep()
} }
if (hasChanged) if (hasChanged)
emit testTreeModelChanged(); emit testTreeModelChanged();
#ifdef WITH_TESTS
if (m_parser->state() == TestCodeParser::Idle && !m_parser->furtherParsingExpected())
emit sweepingDone();
#endif
} }
QMap<QString, QString> TestTreeModel::testCaseNamesForFiles(QStringList files) QMap<QString, QString> TestTreeModel::testCaseNamesForFiles(QStringList files)
......
...@@ -85,6 +85,9 @@ public: ...@@ -85,6 +85,9 @@ public:
signals: signals:
void testTreeModelChanged(); void testTreeModelChanged();
#ifdef WITH_TESTS
void sweepingDone();
#endif
public slots: public slots:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment