QmlProfiler: Output unexpected errors in LocalQmlProfiler test

We want to know why it's failing.

Change-Id: I794f183d8aae7f0f7c6444b432d9a2e80db16f22
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Ulf Hermann
2016-07-22 09:04:55 +02:00
parent 16ca70994b
commit 30eab176fd

View File

@@ -37,6 +37,17 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
{ {
} }
bool checkErrors(const QStringList &errors, int number)
{
if (errors.length() != number) {
qDebug() << "Found unexpected errors:" << errors;
return false;
} else {
return true;
}
}
void LocalQmlProfilerRunnerTest::testRunner() void LocalQmlProfilerRunnerTest::testRunner()
{ {
Debugger::AnalyzerConnection connection; Debugger::AnalyzerConnection connection;
@@ -53,7 +64,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
bool running = false; bool running = false;
int runCount = 0; int runCount = 0;
int errors = 0; QStringList errors;
auto connectRunner = [&]() { auto connectRunner = [&]() {
connect(runner, &LocalQmlProfilerRunner::started, this, [&running, &runCount](){ connect(runner, &LocalQmlProfilerRunner::started, this, [&running, &runCount](){
@@ -68,10 +79,9 @@ void LocalQmlProfilerRunnerTest::testRunner()
connect(runner, &LocalQmlProfilerRunner::appendMessage, this, connect(runner, &LocalQmlProfilerRunner::appendMessage, this,
[&errors](const QString &message, Utils::OutputFormat format) { [&errors](const QString &message, Utils::OutputFormat format) {
Q_UNUSED(message);
if (format == Utils::ErrorMessageFormat && message != if (format == Utils::ErrorMessageFormat && message !=
ProjectExplorer::ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput()) ProjectExplorer::ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput())
++errors; errors << message;
}); });
}; };
@@ -81,7 +91,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
QTRY_COMPARE_WITH_TIMEOUT(runCount, 1, 10000); QTRY_COMPARE_WITH_TIMEOUT(runCount, 1, 10000);
QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000);
QCOMPARE(errors, 1); QVERIFY(checkErrors(errors, 1));
configuration.socket = connection.analyzerSocket = LocalQmlProfilerRunner::findFreeSocket(); configuration.socket = connection.analyzerSocket = LocalQmlProfilerRunner::findFreeSocket();
configuration.debuggee.executable = qApp->applicationFilePath(); configuration.debuggee.executable = qApp->applicationFilePath();
@@ -99,7 +109,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
QTRY_COMPARE_WITH_TIMEOUT(runCount, 2, 10000); QTRY_COMPARE_WITH_TIMEOUT(runCount, 2, 10000);
QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000);
QCOMPARE(errors, 1); QVERIFY(checkErrors(errors, 1));
delete rc; delete rc;
@@ -118,11 +128,11 @@ void LocalQmlProfilerRunnerTest::testRunner()
QTRY_COMPARE_WITH_TIMEOUT(runCount, 3, 10000); QTRY_COMPARE_WITH_TIMEOUT(runCount, 3, 10000);
QTest::qWait(1000); QTest::qWait(1000);
QVERIFY(running); // verify it doesn't spontaneously stop QVERIFY(running); // verify it doesn't spontaneously stop
QCOMPARE(errors, 1); QVERIFY(checkErrors(errors, 1));
rc->stop(); rc->stop();
QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000);
QCOMPARE(errors, 2); // "The program has unexpectedly finished." QVERIFY(checkErrors(errors, 2)); // "The program has unexpectedly finished."
delete rc; delete rc;
} }