From afe18169966eb7e797cb71412eee81cdf527013d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 31 Oct 2019 02:59:28 +0100 Subject: [PATCH 1/2] 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()); From 14398458029b91a92b7d812a093b3340ade54c48 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 31 Oct 2019 13:47:01 +0100 Subject: [PATCH 2/2] Remove extra new lines after GTK log messages This seems unnecessary as the default log handler already outputs a new line at the end of the message anyhow and at least some messages (e.g. debug ones in GdkPixbuf) also contain an extra new line in them, so adding another one here resulted in having at least one and sometimes two extra blank lines. --- tests/test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test.cpp b/tests/test.cpp index 3fb11e9c34..0b4e31d0f0 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -514,8 +514,6 @@ wxTestGLogHandler(const gchar* domain, wxGetCurrentTestName().c_str()); g_log_default_handler(domain, level, message, data); - - fprintf(stderr, "\n"); } #endif // __WXGTK__