diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-10-08 13:58:27 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-11-26 04:47:24 +0100 |
commit | efb283fb7f72e950c8ecf755b960a3c1b36b5507 (patch) | |
tree | 361930e1f30586e93f3b4165a9893cdd381d2517 /src/testlib/qtestlog_p.h | |
parent | 1edf153a6bc28e127531e852a0856025ca5d91b0 (diff) |
Add QTest::failOnWarning
This solves the long-standing problem of not being able to easily
fail a test when a certain warning is output.
[ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test
function, any warning that matches the given pattern will cause a test
failure. The test will continue execution when a failure is added.
All patterns are cleared at the end of each test function.
Fixes: QTBUG-70029
Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qtestlog_p.h')
-rw-r--r-- | src/testlib/qtestlog_p.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index c422aadbf8..cc24360bed 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -105,9 +105,14 @@ public: #ifndef QT_NO_REGULAREXPRESSION static void ignoreMessage(QtMsgType type, const QRegularExpression &expression); #endif + static void failOnWarning(const char *msg); +#ifndef QT_NO_REGULAREXPRESSION + static void failOnWarning(const QRegularExpression &expression); +#endif static int unhandledIgnoreMessages(); static void printUnhandledIgnoreMessages(); static void clearIgnoreMessages(); + static void clearFailOnWarnings(); static void warn(const char *msg, const char *file, int line); static void info(const char *msg, const char *file, int line); |