tests: Set fatal log handler on clutter tests

With Xwayland initialization going async, these errors will seep
into the parts controlled by g_test*(), resulting in the harmless
errors about DBus names not acquired turned fatal.

Set an error log handler, and specifically ignore those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
This commit is contained in:
Carlos Garnacho 2019-11-20 00:06:26 +01:00 committed by Jonas Ådahl
parent 21994bb00d
commit 8c332a4704

View File

@ -12,6 +12,22 @@ typedef struct {
static ClutterTestEnvironment *test_environ = NULL;
#define DBUS_NAME_WARNING "Lost or failed to acquire name"
static gboolean
log_func (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data)
{
if ((log_level & G_LOG_LEVEL_WARNING) &&
g_strcmp0 (log_domain, "mutter") == 0 &&
g_str_has_prefix (message, DBUS_NAME_WARNING))
return FALSE;
return TRUE;
}
/*
* clutter_test_init:
* @argc: (inout): number of arguments in @argv
@ -107,6 +123,8 @@ clutter_test_func_wrapper (gconstpointer data_)
{
const ClutterTestData *data = data_;
g_test_log_set_fatal_handler (log_func, NULL);
/* ensure that the previous test state has been cleaned up */
g_assert_null (test_environ->stage);