Fix tst_qtcprocess when Qt is showing warnings on startup

In my case Qt is persistently showing the following warning
at startup of every application:

Warning: Ignoring WAYLAND_DISPLAY on Gnome.
Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

There is no easy solution here, as even when I run this test
with -platform xcb option, then this test is running
another instance of Creator that doesn't have this option
passed. Since QTest's internal main function parses the
argv options and filters out those recognized by Qt itself,
calling QCoreApplication::arguments() doesn't return
the originally passed -platform xcb option.

The solution here is simple - we ignore initial lines
in callback (so we filter out the initial warnings
generated by Qt) and wait for first expected line.
The final check of parsed line numbers should prevent
the case when we have filtered out all the lines.

Change-Id: Ideff0dc7c409b6e3ad81ec13577cb67e5211d5df
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2022-03-04 17:25:51 +01:00
parent 65dd738a01
commit 809b371108

View File

@@ -1011,8 +1011,13 @@ void tst_QtcProcess::lineCallback()
QStringList lines = QString(lineCallbackData).split('|'); QStringList lines = QString(lineCallbackData).split('|');
int lineNumber = 0; int lineNumber = 0;
process.setStdErrLineCallback([lines, &lineNumber](const QString &actual) { process.setStdErrLineCallback([lines, &lineNumber](const QString &actual) {
QString expected = lines.at(lineNumber++); QString expected = lines.at(lineNumber);
expected.replace("\r\n", "\n"); expected.replace("\r\n", "\n");
// Omit some initial lines generated by Qt, e.g.
// Warning: Ignoring WAYLAND_DISPLAY on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
if (lineNumber == 0 && actual != expected)
return;
++lineNumber;
QCOMPARE(actual, expected); QCOMPARE(actual, expected);
}); });
process.start(); process.start();
@@ -1026,8 +1031,13 @@ void tst_QtcProcess::lineCallbackIntern()
QStringList lines = QString(lineCallbackData).split('|'); QStringList lines = QString(lineCallbackData).split('|');
int lineNumber = 0; int lineNumber = 0;
process.setStdOutLineCallback([lines, &lineNumber](const QString &actual) { process.setStdOutLineCallback([lines, &lineNumber](const QString &actual) {
QString expected = lines.at(lineNumber++); QString expected = lines.at(lineNumber);
expected.replace("\r\n", "\n"); expected.replace("\r\n", "\n");
// Omit some initial lines generated by Qt, e.g.
// Warning: Ignoring WAYLAND_DISPLAY on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
if (lineNumber == 0 && actual != expected)
return;
++lineNumber;
QCOMPARE(actual, expected); QCOMPARE(actual, expected);
}); });
process.beginFeed(); process.beginFeed();