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.
This commit is contained in:
Vadim Zeitlin
2019-10-31 02:59:28 +01:00
parent 349e73994b
commit afe1816996

View File

@@ -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());