tests: Abort tests if there were warnings

This commit is contained in:
Sergio Martins
2022-05-21 00:00:14 +01:00
parent 07fc7d0437
commit bafa21d11c
5 changed files with 19 additions and 25 deletions

View File

@@ -23,6 +23,8 @@
using namespace KDDockWidgets;
#ifdef DOCKS_DEVELOPER_MODE
namespace KDDockWidgets::Tests {
static QtMessageHandler s_original = nullptr;
@@ -54,10 +56,9 @@ static void fatalWarningsMessageHandler(QtMsgType t, const QMessageLogContext &c
{
if (shouldBlacklistWarning(msg, QLatin1String(context.category)))
return;
s_original(t, context, msg);
if (t == QtWarningMsg) {
if (t == QtWarningMsg) {
if (!s_expectedWarning.isEmpty() && msg.contains(s_expectedWarning))
return;
@@ -66,6 +67,7 @@ static void fatalWarningsMessageHandler(QtMsgType t, const QMessageLogContext &c
if (Platform::s_warningObserver)
Platform::s_warningObserver->onFatal();
Platform::instance()->m_numWarningsEmitted++;
QFAIL("Test caused warning");
}
}
@@ -95,7 +97,7 @@ public:
EventFilter::~EventFilter() = default;
}
#endif
Platform_qt::Platform_qt()
{
@@ -251,6 +253,8 @@ void Platform_qt::tests_initPlatform_impl()
void Platform_qt::tests_deinitPlatform_impl()
{
qInstallMessageHandler(Tests::s_original);
Tests::s_original = nullptr;
delete qApp;
}