Merge branch 'test-gtk-log'

Don't output spurious empty log messages when running test suite under
GTK.

Closes https://github.com/wxWidgets/wxWidgets/pull/1625
This commit is contained in:
Vadim Zeitlin
2019-11-01 00:12:44 +01:00

View File

@@ -490,12 +490,30 @@ 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());
g_log_default_handler(domain, level, message, data);
fprintf(stderr, "\n");
}
#endif // __WXGTK__