From 9a86dba130223cc0e40fe4ce0a404be9de7a8b5b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 17 Jun 2024 09:26:48 +0200 Subject: [PATCH] tst_QRegularExpression: port to QTEST_THROW_ON_FAIL Dogfooding the new QtTest 6.8 feature. Change-Id: I530814c0858565b46f462d5c66038a37140c0617 Reviewed-by: Ahmad Samir (cherry picked from commit 7885d5cb220cee04f892ecdba46a1fc3dc65eeae) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/text/CMakeLists.txt | 2 ++ .../text/qregularexpression/CMakeLists.txt | 4 ++++ .../tst_qregularexpression.cpp | 16 ++++------------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/auto/corelib/text/CMakeLists.txt b/tests/auto/corelib/text/CMakeLists.txt index 4d24e674ba3..bee0c5cf44c 100644 --- a/tests/auto/corelib/text/CMakeLists.txt +++ b/tests/auto/corelib/text/CMakeLists.txt @@ -15,7 +15,9 @@ add_subdirectory(qchar) add_subdirectory(qcollator) add_subdirectory(qlatin1stringmatcher) add_subdirectory(qlatin1stringview) +if (NOT WASM) # QTBUG-121822 add_subdirectory(qregularexpression) +endif() add_subdirectory(qstring) add_subdirectory(qstring_no_cast_from_bytearray) add_subdirectory(qstringapisymmetry) diff --git a/tests/auto/corelib/text/qregularexpression/CMakeLists.txt b/tests/auto/corelib/text/qregularexpression/CMakeLists.txt index a7a7fe298f2..2c67a161843 100644 --- a/tests/auto/corelib/text/qregularexpression/CMakeLists.txt +++ b/tests/auto/corelib/text/qregularexpression/CMakeLists.txt @@ -14,6 +14,10 @@ endif() qt_internal_add_test(tst_qregularexpression SOURCES tst_qregularexpression.cpp + NO_BATCH # QTBUG-121815 + DEFINES + QTEST_THROW_ON_FAIL + QTEST_THROW_ON_SKIP LIBRARIES Qt::TestPrivate ) diff --git a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp index d0ce4140953..53a6d83d502 100644 --- a/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/text/qregularexpression/tst_qregularexpression.cpp @@ -16,6 +16,10 @@ #include #include +#ifndef QTEST_THROW_ON_FAIL +# error This test requires QTEST_THROW_ON_FAIL being active. +#endif + Q_DECLARE_METATYPE(QRegularExpression::PatternOptions) Q_DECLARE_METATYPE(QRegularExpression::MatchType) Q_DECLARE_METATYPE(QRegularExpression::MatchOptions) @@ -292,11 +296,7 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator) QRegularExpressionMatch peeked = i.peekNext(); QRegularExpressionMatch match = i.next(); consistencyCheck(peeked); - if (QTest::currentTestFailed()) - return; consistencyCheck(match); - if (QTest::currentTestFailed()) - return; QVERIFY(match.isValid()); QVERIFY(match.hasMatch() || match.hasPartialMatch()); QCOMPARE(i.regularExpression(), match.regularExpression()); @@ -544,8 +544,6 @@ void tst_QRegularExpression::moveSemanticsMatch() QCOMPARE(match2.capturedStart(), 3); QCOMPARE(match2.capturedEnd(), 7); consistencyCheck(match2); - if (QTest::currentTestFailed()) - return; QRegularExpressionMatch match3 = re.match("test1"); QCOMPARE(match3.hasMatch(), true); @@ -558,8 +556,6 @@ void tst_QRegularExpression::moveSemanticsMatch() QCOMPARE(match1.capturedStart(), 0); QCOMPARE(match1.capturedEnd(), 4); consistencyCheck(match1); - if (QTest::currentTestFailed()) - return; // here match3 is in the moved-from state, so destructor call for moved-from // object is also checked @@ -578,8 +574,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator() QVERIFY(it2.hasNext()); QT_TEST_EQUALITY_OPS(it2.regularExpression(), re, true); consistencyCheck(it2); - if (QTest::currentTestFailed()) - return; QRegularExpression re2("test"); QRegularExpressionMatchIterator it3 = re2.globalMatch("123test456"); @@ -593,8 +587,6 @@ void tst_QRegularExpression::moveSemanticsMatchIterator() QVERIFY(it1.hasNext()); QT_TEST_EQUALITY_OPS(it1.regularExpression(), re2, true); consistencyCheck(it1); - if (QTest::currentTestFailed()) - return; // here it3 is in the moved-from state, so destructor call for moved-from // object is also checked