From 5d80d24d3c1a58c7e617e7b671e3040039cde684 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 10 Dec 2021 17:14:35 +0100 Subject: Tidy up tst_Warnings: comments and #if-ery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was missing #if-ery on feature regularexpression for one test that depends on it. One of its comments had a long line. Added some annotations to make clear what's going on in messier tests. Change-Id: I06d8748a134591f93b36029713e52ffd826a24dc Reviewed-by: Tor Arne Vestbø --- tests/auto/testlib/selftests/warnings/tst_warnings.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/auto/testlib') diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp index ee73bd4fe4..40ebb17561 100644 --- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp +++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp @@ -37,7 +37,9 @@ class tst_Warnings: public QObject private slots: void testWarnings(); void testMissingWarnings(); +#if QT_CONFIG(regularexpression) void testMissingWarningsRegularExpression(); +#endif void testMissingWarningsWithData_data(); void testMissingWarningsWithData(); @@ -109,6 +111,7 @@ void tst_Warnings::testMissingWarnings() qWarning("Warning2"); } +#if QT_CONFIG(regularexpression) void tst_Warnings::testMissingWarningsRegularExpression() { QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\d\\d")); @@ -116,6 +119,7 @@ void tst_Warnings::testMissingWarningsRegularExpression() qWarning("Warning11"); } +#endif void tst_Warnings::testMissingWarningsWithData_data() { @@ -172,8 +176,9 @@ void tst_Warnings::testFailOnWarnings() void tst_Warnings::testFailOnWarningsCleared() { // The patterns passed to failOnWarnings() should be cleared at the end of - // each test function, so this shouldn't fail because of the failOnWarning() call in the previous function. - // Note that this test always needs to come after testFailOnWarnings for it to work. + // each test function, so this shouldn't fail because of the failOnWarning() + // call in the previous function. Note that this test always needs to come + // after testFailOnWarnings for it to test anything meaningfully. qWarning("Ran out of muffins!"); } @@ -203,6 +208,7 @@ void tst_Warnings::testFailOnWarningsWithData() void tst_Warnings::testFailOnWarningsFailInHelper() { [](){ QFAIL("This failure message should be printed but not cause the test to abort"); }(); + // So we've already failed, but we get more messages - that don't increment counters. const auto warnRegex = QRegularExpression("Ran out of .*!"); QTest::failOnWarning(warnRegex); qWarning("Ran out of cabbage!"); @@ -214,7 +220,7 @@ void tst_Warnings::testFailOnWarningsThenSkip() const auto warnRegex = QRegularExpression("Ran out of .*!"); QTest::failOnWarning(warnRegex); qWarning("Ran out of cabbage!"); - QSKIP("My cabbage! :("); + QSKIP("My cabbage! :("); // Reports, but doesn't count. } #endif // QT_CONFIG(regularexpression) -- cgit v1.2.3