From afe18169966eb7e797cb71412eee81cdf527013d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 31 Oct 2019 02:59:28 +0100 Subject: [PATCH] Ignore GTK debug logs in the unit test unless they're enabled Don't output "*** GTK log message while running" messages for every g_debug() call when we the debug messages themselves will not be displayed because G_MESSAGES_DEBUG is not set or its value doesn't include the domain used by the message. This results in much more reasonable output from the test suite. See #17400. --- tests/test.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test.cpp b/tests/test.cpp index 1d42529be5..3fb11e9c34 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -490,6 +490,26 @@ wxTestGLogHandler(const gchar* domain, const gchar* message, gpointer data) { + // Check if debug messages in this domain will be logged. + if ( level == G_LOG_LEVEL_DEBUG ) + { + static consr char* const allowed = getenv("G_MESSAGES_DEBUG"); + + // By default debug messages are dropped, but if G_MESSAGES_DEBUG is + // defined, they're logged for the domains specified in it and if it + // has the special value "all", then all debug messages are shown. + // + // Note that the check here can result in false positives, e.g. domain + // "foo" would pass it even if G_MESSAGES_DEBUG only contains "foobar", + // but such cases don't seem to be important enough to bother + // accounting for them. + if ( !allowed || + (strcmp(allowed, "all") != 0 && !strstr(allowed, domain)) ) + { + return; + } + } + fprintf(stderr, "\n*** GTK log message while running %s(): ", wxGetCurrentTestName().c_str());