From f61c1a1be146751e76acb012b3f71605901b78af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 2 Mar 2021 18:51:05 +0100 Subject: [PATCH] context/test: Add 'run-tests' signal that can replace g_test_run() For tests that doesn't use g_test_run(). Part-of: --- src/tests/meta-context-test.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c index dce9aa523..0a490913a 100644 --- a/src/tests/meta-context-test.c +++ b/src/tests/meta-context-test.c @@ -37,6 +37,7 @@ enum { BEFORE_TESTS, + RUN_TESTS, AFTER_TESTS, N_SIGNALS }; @@ -162,7 +163,15 @@ run_tests_idle (gpointer user_data) int ret; g_signal_emit (context, signals[BEFORE_TESTS], 0); - ret = g_test_run (); + if (g_signal_has_handler_pending (context, signals[RUN_TESTS], 0, TRUE)) + { + g_signal_emit (context, signals[RUN_TESTS], 0, &ret); + g_assert (ret == 1 || ret == 0); + } + else + { + ret = g_test_run (); + } g_signal_emit (context, signals[AFTER_TESTS], 0); if (ret != 0) @@ -246,6 +255,14 @@ meta_context_test_class_init (MetaContextTestClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); + signals[RUN_TESTS] = + g_signal_new ("run-tests", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_INT, + 0); signals[AFTER_TESTS] = g_signal_new ("after-tests", G_TYPE_FROM_CLASS (klass),