[mutter] context/test: Add 'run-tests' signal that can replace g_test_run()



commit f61c1a1be146751e76acb012b3f71605901b78af
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 18:51:05 2021 +0100

    context/test: Add 'run-tests' signal that can replace g_test_run()
    
    For tests that doesn't use g_test_run().
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 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 dce9aa523d..0a490913a3 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),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]