summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-11-26 14:09:20 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-12-09 20:54:25 +0100
commitd41d3274d430922883afd714d87d81cf0e62d5d9 (patch)
tree6fbc9df4f63f5e559490a474424b9866764233de
parent37bc11e707d3f29fa81675bcc41610ab65c2b314 (diff)
Replace out-of-date comment on QTRY_IMPL(), about qWaitFor()
A comment on QTRY_IMPL() helpfully mentioned the bug number of the issue that prevented us from using qWaitFor; and MSVC < 2017 are no longer supported so it looked possible to make the change suggested. However, the implementation has, in the mean time, grown some features not (currently) provided by qWaitFor(), so update the comment. In the process, fix one minor error in QTRY_TIMEOUT_DEBUG_IMPL() where parentheses enclosed the wrong text; (2 * timeoutValue) would not produce the intended result if timeoutValue were 1 + 500, for example. The macro parameter should be enclosed, not the expression using it as parameter to a further macro. Task-number: QTBUG-59096 Change-Id: Ie16e297def9d1f983cd5964bc628b2c3c0aaecda Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/testlib/qtestcase.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 8dca291303..80cece7f9a 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -154,6 +154,14 @@ inline void useVerifyThrowsException() {}
#endif // !QT_NO_EXCEPTIONS
+/* Ideally we would adapt qWaitFor(), or a variant on it, to implement roughly
+ * what the following provides as QTRY_LOOP_IMPL(); however, for now, the
+ * reporting of how much to increase the timeout to (if within a factor of two)
+ * on failure and the check for QTest::currentTestFailed() go beyond
+ * qWaitFor(). (We no longer care about the bug in MSVC < 2017 that precluded
+ * using qWaitFor() in the implementation here, see QTBUG-59096.)
+ */
+
// NB: not do {...} while (0) wrapped, as qt_test_i is accessed after it
#define QTRY_LOOP_IMPL(expr, timeoutValue, step) \
if (!(expr)) { \
@@ -166,14 +174,12 @@ inline void useVerifyThrowsException() {}
#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)\
if (!(expr)) { \
- QTRY_LOOP_IMPL((expr), (2 * timeoutValue), step);\
+ QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \
if (expr) { \
QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \
} \
}
-// Ideally we'd use qWaitFor instead of QTRY_LOOP_IMPL, but due
-// to a compiler bug on MSVC < 2017 we can't (see QTBUG-59096)
#define QTRY_IMPL(expr, timeout)\
const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \
const int qt_test_timeoutValue = timeout; \