Commit bfa292cd authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

ClangStaticAnalyzer: Tests: Fix failing runner tests on Windows



Both runner tests fail on Windows at

	QVERIFY(st.expectStartedSignal());

because QProcess::started() is emitted before ClangStaticAnalyzerRunner::run()
returns and thus before QSignalSpy::wait() is reached.

Watch out for the signal manually before calling run().

Change-Id: Ia786bfc6c859a4a4b420aeccc7e7f7bb0b4c47c0
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent cfa9dd4c
......@@ -81,6 +81,7 @@ public:
bool expectFinishWithFailureSignal(const QString &expectedErrorMessage = QString());
private:
int m_startedSignalEmitted;
QSignalSpy m_spyStarted;
QSignalSpy m_spyFinishedWithFailure;
QSignalSpy m_spyFinishedWithSuccess;
......@@ -88,25 +89,37 @@ private:
ClangStaticAnalyzerRunnerSignalTester::ClangStaticAnalyzerRunnerSignalTester(
ClangStaticAnalyzerRunner *runner)
: m_spyStarted(runner, SIGNAL(started()))
: m_startedSignalEmitted(0)
, m_spyStarted(runner, SIGNAL(started()))
, m_spyFinishedWithFailure(runner, SIGNAL(finishedWithFailure(QString,QString)))
, m_spyFinishedWithSuccess(runner, SIGNAL(finishedWithSuccess(QString)))
{
// On Windows started() is emitted before ClangStaticAnalyzerRunner::run()
// returns and thus before we reach QSignalSpy::wait(). Ensure that we will
// get notified about those early started() signals.
QObject::connect(runner, &ClangStaticAnalyzerRunner::started, [this] {
++m_startedSignalEmitted;
});
}
bool ClangStaticAnalyzerRunnerSignalTester::expectStartedSignal()
{
if (m_spyStarted.wait()) {
if (m_spyStarted.size() != 1) {
qDebug() << "started() emitted more than once.";
return false;
}
} else {
qDebug() << "started() not emitted.";
if (m_startedSignalEmitted != 0) {
if (m_startedSignalEmitted == 1)
return true;
qDebug() << "started() emitted more than once.";
return false;
} else if (m_spyStarted.wait()) {
if (m_spyStarted.size() == 1)
return true;
qDebug() << "started() emitted more than once.";
return false;
}
return true;
qDebug() << "started() not emitted.";
return false;
}
bool ClangStaticAnalyzerRunnerSignalTester::expectFinishWithSuccessSignal()
......
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