summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
diff options
context:
space:
mode:
authorM. Moellney <mail@michaelmoellney.de>2016-03-19 22:00:32 +0100
committerMichael Möllney <mail@michaelmoellney.de>2016-03-25 11:03:43 +0000
commit705d29585b9a006b2fc8dd77ebf7a67b3670011b (patch)
tree8ad31b8b6c8fa2fde78319d9e83614683b5b55a1 /tests/auto/corelib/global/qlogging/tst_qlogging.cpp
parent2e385b3d74ffbcad820b36b717f9215cc7b86720 (diff)
Fix qSetMessagePattern to have many time/backtrace parts
The previous implementation overwrote multiple 'time' parts in the qSetMessagePattern with the last setting in the pattern line. %{time}%{time process}%{time boot} ended up to be output as if %{time boot}%{time boot}%{time boot} was set. This fix keeps the arguments of each individual 'time' part. The same holds for multiple 'backtrace' parts. The previouse implementation overwrote multiple 'backtrace' arguments with the arguments of the last occurrence. This fix keeps the individual arguments for the 'process' parts. The individual arguments are applied in qFormatLogMessage. A new test to verify the individual 'time' arguments application is added, too. Task-number: QTBUG-51944 Change-Id: Ib757614a482c5f31ed0a61b550daa2eea4b907b4 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/global/qlogging/tst_qlogging.cpp')
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index a65a72313f..618806f3cd 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -779,6 +779,17 @@ void tst_qmessagehandler::qMessagePattern_data()
<< true << (QList<QByteArray>()
<< ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8() + "/qDebug"));
+ QTest::newRow("time-time") << "/%{time yyyy - MM - d}/%{time dd-MM-yy}/%{message}"
+ << true << (QList<QByteArray>()
+ << ('/' + QDateTime::currentDateTime().toString("yyyy - MM - d").toUtf8()
+ + '/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8()
+ + "/qDebug"));
+
+ QTest::newRow("skipped-time-shown-time")
+ << "/%{if-warning}%{time yyyy - MM - d}%{endif}%{if-debug}%{time dd-MM-yy}%{endif}/%{message}"
+ << true << (QList<QByteArray>()
+ << ('/' + QDateTime::currentDateTime().toString("dd-MM-yy").toUtf8() + "/qDebug"));
+
// %{time} should have a padding of 6 so if it takes less than 10 seconds to show
// the first message, there should be 5 spaces
QTest::newRow("time-process") << "<%{time process}>%{message}" << true << (QList<QByteArray>()