tests: Call g_test_init() in test-runner too
This makes the log handler that breaks test redundant, as GTest already does this.
This commit is contained in:
@ -37,7 +37,6 @@
|
||||
typedef struct {
|
||||
GHashTable *clients;
|
||||
AsyncWaiter *waiter;
|
||||
guint log_handler_id;
|
||||
GString *warning_messages;
|
||||
GMainLoop *loop;
|
||||
} TestCase;
|
||||
@ -62,49 +61,11 @@ test_case_alarm_filter (MetaX11Display *x11_display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
test_case_check_warnings (TestCase *test,
|
||||
GError **error)
|
||||
{
|
||||
if (test->warning_messages != NULL)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_RUNTIME_ERROR,
|
||||
"Warning messages:\n %s", test->warning_messages->str);
|
||||
g_string_free (test->warning_messages, TRUE);
|
||||
test->warning_messages = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_case_log_func (const gchar *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
const gchar *message,
|
||||
gpointer user_data)
|
||||
{
|
||||
TestCase *test = user_data;
|
||||
|
||||
if (test->warning_messages == NULL)
|
||||
test->warning_messages = g_string_new (message);
|
||||
else
|
||||
{
|
||||
g_string_append (test->warning_messages, "\n ");
|
||||
g_string_append (test->warning_messages, message);
|
||||
}
|
||||
}
|
||||
|
||||
static TestCase *
|
||||
test_case_new (void)
|
||||
{
|
||||
TestCase *test = g_new0 (TestCase, 1);
|
||||
|
||||
test->log_handler_id = g_log_set_handler ("mutter",
|
||||
G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
test_case_log_func,
|
||||
test);
|
||||
|
||||
meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display,
|
||||
test_case_alarm_filter, test);
|
||||
|
||||
@ -529,7 +490,7 @@ test_case_do (TestCase *test,
|
||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||
}
|
||||
|
||||
return test_case_check_warnings (test, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -557,9 +518,6 @@ test_case_destroy (TestCase *test,
|
||||
if (!test_case_assert_stacking (test, NULL, 0, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_check_warnings (test, error))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_iter_init (&iter, test->clients);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
test_client_destroy (value);
|
||||
@ -572,8 +530,6 @@ test_case_destroy (TestCase *test,
|
||||
g_hash_table_destroy (test->clients);
|
||||
g_free (test);
|
||||
|
||||
g_log_remove_handler ("mutter", test->log_handler_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -795,7 +751,7 @@ main (int argc, char **argv)
|
||||
|
||||
g_option_context_free (ctx);
|
||||
|
||||
test_init (argc, argv);
|
||||
test_init (&argc, &argv);
|
||||
|
||||
GPtrArray *tests = g_ptr_array_new ();
|
||||
|
||||
|
Reference in New Issue
Block a user