summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-04-29 14:11:39 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-05-08 09:51:38 +0200
commit2491ee98b10d0ea2bb33f341b2efa478c50904b2 (patch)
tree9db33c6e5908c9599ecb7ca626c0eab6f00a7902
parente325bd68fd6bdcbcb0c4e7478cb6371b60d89905 (diff)
QTest::ignoreMessage(): interpret the message in UTF-8
The message to ignore is given in source code, hence UTF-8; it was being ingested as local 8-bit, which lead to problems when a debug message wasn't 7-bit clean and the system's native encoding wasn't UTF-8. Modified QtTest's selftest to check encoding failure. Pick-to: 5.15 Change-Id: I898744a450115b6d2ee992f1d3b36d8efaeeff7e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/testlib/qtestlog.cpp4
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp10
2 files changed, 11 insertions, 3 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index a388780532..be50176a08 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
@@ -521,7 +521,7 @@ void QTestLog::ignoreMessage(QtMsgType type, const char *msg)
{
QTEST_ASSERT(msg);
- QTest::IgnoreResultList::append(QTest::ignoreResultList, type, QString::fromLocal8Bit(msg));
+ QTest::IgnoreResultList::append(QTest::ignoreResultList, type, QString::fromUtf8(msg));
}
#if QT_CONFIG(regularexpression)
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index 57c5f8597b..cdad72bd57 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -80,6 +80,14 @@ void tst_Warnings::testWarnings()
// accept redundant space at end to keep compatibility with Qt < 5.2
QTest::ignoreMessage(QtDebugMsg, "Bubu ");
qDebug() << "Bubu";
+
+ // Cope with non-ASCII messages; should be understood as UTF-8 (it comes
+ // from source code on both sides), even if the system encoding is
+ // different:
+ QTest::ignoreMessage(QtDebugMsg, "Hej v\xc3\xa4rlden");
+ qDebug() << "Hej v\xc3\xa4rlden";
+ QTest::ignoreMessage(QtInfoMsg, "Hej v\xc3\xa4rlden");
+ qInfo() << "Hej v\xc3\xa4rlden";
}
void tst_Warnings::testMissingWarnings()