summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/testlib/qtestlog.cpp16
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp4
2 files changed, 19 insertions, 1 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 0e67335222..b2efa1ac9c 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -111,11 +111,25 @@ namespace QTest {
last->next = item;
}
+ static bool stringsMatch(const QString &expected, const QString &actual)
+ {
+ if (expected == actual)
+ return true;
+
+ // ignore an optional whitespace at the end of str
+ // (the space was added automatically by ~QDebug() until Qt 5.3,
+ // so autotests still might expect it)
+ if (expected.endsWith(QLatin1Char(' ')))
+ return actual == expected.leftRef(expected.length() - 1);
+
+ return false;
+ }
+
inline bool matches(QtMsgType tp, const QString &message) const
{
return tp == type
&& (pattern.type() == QVariant::String ?
- pattern.toString() == message :
+ stringsMatch(pattern.toString(), message) :
pattern.toRegularExpression().match(message).hasMatch());
}
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index ff4357f11f..4e3620caab 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -82,6 +82,10 @@ void tst_Warnings::testWarnings()
qWarning("Babablabla");
qDebug("Bubublabla");
qWarning("Babablabla");
+
+ // accept redundant space at end to keep compatibility with Qt < 5.2
+ QTest::ignoreMessage(QtDebugMsg, "Bubu ");
+ qDebug() << "Bubu";
}
void tst_Warnings::testMissingWarnings()