diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-21 22:38:47 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-22 23:23:16 +0200 |
commit | e7371c19d9ab89847115efbe490a23c24c23f20b (patch) | |
tree | 558a84b60707509687ee0955e4f0e4eb99f135c0 /src/testlib/qtestcase.cpp | |
parent | 304ec18a1ada480f45d1831c24af9b341cf62b67 (diff) |
testlib: Defer signal dumper start until tests are ready to run
We don't want the signal dumper to pick up signals that our own
test machinery produces, such as the ones emitted from the watchdog
thread startup and shutdown. This would otherwise produce:
tst_Signaldumper::initTestCase() Signal: QThread(7fc969e0d870) started ()
At startup, and at shutdown even more confusingly:
tst_Signaldumper::UnknownTestFunc() Signal: QThread(7fc969e0d870) finished ()
Change-Id: I9e81fa168eaa92551d38d5576973bbf95ac23364
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index e352f72e20..6b55ae43c6 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -643,7 +643,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool } else if (strcmp(argv[i], "-v2") == 0) { QTestLog::setVerboseLevel(2); } else if (strcmp(argv[i], "-vs") == 0) { - QSignalDumper::startDump(); + QSignalDumper::setEnabled(true); } else if (strcmp(argv[i], "-o") == 0) { if (i + 1 >= argc) { fprintf(stderr, "-o needs an extra parameter specifying the filename and optional format\n"); @@ -1485,6 +1485,8 @@ void TestMethods::invokeTests(QObject *testObject) const watchDog.reset(new WatchDog); } + QSignalDumper::startDump(); + if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) { if (m_initTestCaseMethod.isValid()) m_initTestCaseMethod.invoke(testObject, Qt::DirectConnection); @@ -1517,6 +1519,8 @@ void TestMethods::invokeTests(QObject *testObject) const } QTestResult::finishedCurrentTestFunction(); QTestResult::setCurrentTestFunction(nullptr); + + QSignalDumper::endDump(); } #if defined(Q_OS_WIN) @@ -1965,8 +1969,6 @@ void QTest::qCleanup() delete QBenchmarkGlobalData::current; QBenchmarkGlobalData::current = nullptr; - QSignalDumper::endDump(); - #if defined(Q_OS_MACOS) IOPMAssertionRelease(macPowerSavingDisabled); #endif |