From e75e89f9dedcdd4b9fe1caa04a2d8c5e759ea068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Feb 2019 16:09:59 +0100 Subject: Test QTest's signal dumper It has been completely untested for a while and saw some breakage. So let's add a selftest for it. ('-vs' when running tests) Change-Id: Ibfb5ac0a2d741de7c3f519d91202d4977996045e Reviewed-by: Qt CI Bot Reviewed-by: Edward Welbourne --- tests/auto/testlib/selftests/tst_selftests.cpp | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/auto/testlib/selftests/tst_selftests.cpp') diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 3ef15b9261..7216c6a373 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -488,6 +488,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "signaldumper" << "silent" << "singleskip" << "skip" @@ -553,6 +554,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "signaldumper") { + arguments << "-vs"; + } else if (subtest == "silent") { arguments << "-silent"; } @@ -953,6 +957,29 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, if (actualLine.startsWith(QLatin1String("Totals:")) && expectedLine.startsWith(QLatin1String("Totals:"))) return true; + const QLatin1String pointerPlaceholder("_POINTER_"); + if (expectedLine.contains(pointerPlaceholder) + && (expectedLine.contains(QLatin1String("Signal: ")) + || expectedLine.contains(QLatin1String("Slot: ")))) { + QString actual = actualLine; + // We don't care about the pointer of the object to whom the signal belongs, so we + // replace it with _POINTER_, e.g.: + // Signal: SignalSlotClass(7ffd72245410) signalWithoutParameters () + // Signal: QThread(7ffd72245410) started () + // After this instance pointer we may have further pointers and + // references (with an @ prefix) as parameters of the signal or + // slot being invoked. + // Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@55f5fbb8dd40) + actual.replace(QRegularExpression("\\b[a-f0-9]{8,}\\b"), pointerPlaceholder); + // Also change QEventDispatcher{Glib,Win32,etc.} to QEventDispatcherPlatform + actual.replace(QRegularExpression("\\b(QEventDispatcher)\\w+\\b"), QLatin1String("\\1Platform")); + if (actual != expectedLine) { + *errorMessage = msgMismatch(actual, expectedLine); + return false; + } + return true; + } + *errorMessage = msgMismatch(actualLine, expectedLine); return false; } -- cgit v1.2.3