From 99b1fd0032b9ffc4251b3c9c7f8e2d2608b4fec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Tue, 28 Jan 2025 14:59:15 +0100 Subject: [PATCH] QTest: Reset repeat counter for each call to QTest::qRun() This fix ensures that each call to QTest::qRun() runs all tests the requested number of repetitions. This fixes an issue where QTEST_QUICKCONTROLS_MAIN would only test the first style, and skip remaining styles. The cause was that the repeat counter was not reset between QTest::qRun() calls. Subsequent calls to QTest::qRun() would therefore not run any tests. Amends: 80a14c86b2739492d7f7fbdb1cbde1da85d1341d Fixes: QTBUG-133207 Pick-to: 6.7 Change-Id: Idb164fd01ac0b8e04e5dd74c3625f2c343f742c5 Reviewed-by: Mitch Curtis (cherry picked from commit 07318c81a700b4d4a46c81ae2e4f17c6b1e501c0) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 9f1893855b2aab36823358056d446f1a2d5e3625) --- src/testlib/qtestcase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 0b6c01e414..d7254404f9 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -427,7 +427,6 @@ static int eventDelay = -1; static int timeout = -1; #endif static int repetitions = 1; -static bool repeatForever = false; static bool skipBlacklisted = false; namespace Internal { @@ -611,7 +610,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool const char *logFilename = nullptr; repetitions = 1; - repeatForever = false; QTest::testFunctions.clear(); QTest::testTags.clear(); @@ -835,7 +833,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool exit(1); } else { repetitions = qToInt(argv[++i]); - repeatForever = repetitions < 0; } } else if (strcmp(argv[i], "-nocrashhandler") == 0) { QTest::Internal::noCrashHandler = true; @@ -1971,7 +1968,9 @@ int QTest::qRun() } TestMethods test(currentTestObject, std::move(commandLineMethods)); - while (QTestLog::failCount() == 0 && (repeatForever || repetitions-- > 0)) { + int remainingRepetitions = repetitions; + const bool repeatForever = repetitions < 0; + while (QTestLog::failCount() == 0 && (repeatForever || remainingRepetitions-- > 0)) { QTestTable::globalTestTable(); test.invokeTests(currentTestObject); QTestTable::clearGlobalTestTable();