summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-07-05 19:27:10 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2022-09-22 17:34:51 +0200
commit75d59c9502364889af2a279c27f545224aff61fa (patch)
treea99df4ce072ed3ced6a12b1933636a4a81d90859 /src/testlib/qtestcase.cpp
parent1fa0e86995bfdf9c0507fcd097fce712554a769e (diff)
Add QTest::currentTestResolved() and use in testlib
The QTRY_* macros and QTestEventLoop have (since 6.3) been exiting their loops early if the test has failed. Where that was appropriate, they should also have been exiting early on skip. [ChangeLog][QtTest] Added QTest::currentTestResolved(), which is true if the test has failed or skipped. The QTRY_*() macros and QTestEventLoop now use this, rather than QTest::currentTestFailed(), to test whether they should stop looping, so that they also do so on a skip. Task-number: QTBUG-104441 Change-Id: Ibf3d5a095b35e6670bc3daf756f05b66f7f3ef9b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index ceee26f36c..22aa3541ff 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -3008,7 +3008,9 @@ const char *QTest::currentDataTag()
}
/*!
- Returns \c true if the current test function failed, otherwise false.
+ Returns \c true if the current test function has failed, otherwise false.
+
+ \sa QTest::currentTestResolved()
*/
bool QTest::currentTestFailed()
{
@@ -3016,12 +3018,30 @@ bool QTest::currentTestFailed()
}
/*!
+ \since 6.5
+ Returns \c true if the current test function has failed or skipped.
+
+ This applies if the test has failed or exercised a skip. When it is true,
+ the test function should return early. In particular, the \c{QTRY_*} macros
+ and \l QTestEventLoop terminate their loops early if executed during the
+ test function (but not its cleanup()). After a test has called a helper
+ function that uses this module's macros, it can use this function to test
+ whether to return early.
+
+ \sa QTest::currentTestFailed()
+*/
+bool QTest::currentTestResolved()
+{
+ return QTestResult::currentTestFailed() || QTestResult::skipCurrentTest();
+}
+
+/*!
\internal
\since 6.4
Returns \c true during the run of the test-function and its set-up.
Used by the \c{QTRY_*} macros and \l QTestEventLoop to check whether to
- return when QTest::currentTestFailed() is true.
+ return when QTest::currentTestResolved() is true.
*/
bool QTest::runningTest()
{