diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-07-11 12:16:13 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-07-25 19:29:07 +0200 |
commit | 4048efc80c3085b7174b746bec1fa8406c56ed42 (patch) | |
tree | 70cda64a548fdf270e3f0f90e2836c69f6fe9166 /src/testlib/qtestcase.h | |
parent | 21e9c223b753ade33c994c1efabbd67978eda3bf (diff) | |
download | qtbase-4048efc80c3085b7174b746bec1fa8406c56ed42.tar.gz |
Move the early-failure checks in QTRY_IMPL()
These checks should not be included in the #expr reported when the
test fails. They're an internal implementation detail of the loop.
Split a long line while I was about it.
Pick-to: 6.4
Change-Id: Iaea0478967d01cd72ef5a5e9a6501d4be2324b18
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index d8ad48d2c0..3103cdc41c 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -159,23 +159,25 @@ inline void useVerifyThrowsException() {} QTest::qWait(0); \ } \ int qt_test_i = 0; \ - for (; qt_test_i < timeoutValue && !(expr); qt_test_i += step) { \ + for (; qt_test_i < timeoutValue && !QTest::currentTestFailed() \ + && !(expr); qt_test_i += step) { \ QTest::qWait(step); \ } -#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)\ - if (!(expr)) { \ +#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step) \ + if (!QTest::currentTestFailed() && !(expr)) { \ QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \ if (expr) { \ - QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \ + QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(\ + u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \ } \ } #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \ const int qt_test_timeoutValue = timeout; \ - { QTRY_LOOP_IMPL(QTest::currentTestFailed() || (expr), qt_test_timeoutValue, qt_test_step); } \ - QTRY_TIMEOUT_DEBUG_IMPL(QTest::currentTestFailed() || (expr), qt_test_timeoutValue, qt_test_step) + { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \ + QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step) // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \ |