[mutter/gnome-41] tests: Split out Wayland tests into its own test case



commit 15813e8f9230e851d7074e3d41490f57227f381e
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Nov 8 10:52:48 2021 +0100

    tests: Split out Wayland tests into its own test case
    
    Makes it easier to run it, as one doesn't need to wait for all the other
    unit tests.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
    (cherry picked from commit d420a39a026644eb4d44c7c212f530a62a6e09d1)

 src/tests/meson.build          | 28 ++++++++++++++++++++++------
 src/tests/unit-tests.c         |  4 ----
 src/tests/wayland-unit-tests.c | 24 ++++++++++++++++++++----
 src/tests/wayland-unit-tests.h | 25 -------------------------
 4 files changed, 42 insertions(+), 39 deletions(-)
---
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 3d0aec394c..9b8d48563a 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -131,8 +131,6 @@ unit_tests = executable('mutter-test-unit-tests',
     'unit-tests.c',
     'boxes-tests.c',
     'boxes-tests.h',
-    'meta-wayland-test-driver.c',
-    'meta-wayland-test-driver.h',
     'meta-gpu-test.c',
     'meta-gpu-test.h',
     'monitor-config-migration-unit-tests.c',
@@ -146,10 +144,6 @@ unit_tests = executable('mutter-test-unit-tests',
     'monitor-unit-tests.c',
     'orientation-manager-unit-tests.c',
     'monitor-unit-tests.h',
-    'wayland-unit-tests.c',
-    'wayland-unit-tests.h',
-    test_driver_server_header,
-    test_driver_protocol_code,
   ],
   include_directories: tests_includes,
   c_args: tests_c_args,
@@ -182,6 +176,21 @@ stage_view_tests = executable('mutter-stage-view-tests',
   install_dir: mutter_installed_tests_libexecdir,
 )
 
+wayland_tests = executable('mutter-wayland-tests',
+  sources: [
+    'meta-wayland-test-driver.c',
+    'meta-wayland-test-driver.h',
+    'wayland-unit-tests.c',
+    test_driver_server_header,
+    test_driver_protocol_code,
+  ],
+  include_directories: tests_includes,
+  c_args: tests_c_args,
+  dependencies: libmutter_test_dep,
+  install: have_installed_tests,
+  install_dir: mutter_installed_tests_libexecdir,
+)
+
 anonymous_file_test = executable('anonymous-file-tests',
   sources: [
     'anonymous-file.c',
@@ -327,6 +336,13 @@ test('stage-view', stage_view_tests,
   timeout: 60,
 )
 
+test('wayland', wayland_tests,
+  suite: ['core', 'mutter/unit'],
+  env: test_env,
+  is_parallel: false,
+  timeout: 60,
+)
+
 test('anonymous-file', anonymous_file_test,
   suite: ['core', 'mutter/unit'],
   env: test_env,
diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c
index 20f965ce4d..0dba16535c 100644
--- a/src/tests/unit-tests.c
+++ b/src/tests/unit-tests.c
@@ -37,7 +37,6 @@
 #include "tests/monitor-transform-tests.h"
 #include "tests/meta-test-utils.h"
 #include "tests/orientation-manager-unit-tests.h"
-#include "tests/wayland-unit-tests.h"
 
 MetaContext *test_context;
 
@@ -232,7 +231,6 @@ init_tests (void)
   init_monitor_config_migration_tests ();
   init_monitor_tests ();
   init_boxes_tests ();
-  init_wayland_tests ();
   init_monitor_transform_tests ();
   init_orientation_manager_tests ();
 }
@@ -252,8 +250,6 @@ main (int argc, char *argv[])
 
   g_signal_connect (context, "before-tests",
                     G_CALLBACK (pre_run_monitor_tests), NULL);
-  g_signal_connect (context, "before-tests",
-                    G_CALLBACK (pre_run_wayland_tests), NULL);
   g_signal_connect (context, "after-tests",
                     G_CALLBACK (finish_monitor_tests), NULL);
 
diff --git a/src/tests/wayland-unit-tests.c b/src/tests/wayland-unit-tests.c
index 9dd3831c6d..f7a5d15d08 100644
--- a/src/tests/wayland-unit-tests.c
+++ b/src/tests/wayland-unit-tests.c
@@ -17,12 +17,11 @@
 
 #include "config.h"
 
-#include "tests/wayland-unit-tests.h"
-
 #include <gio/gio.h>
 
 #include "core/display-private.h"
 #include "core/window-private.h"
+#include "meta-test/meta-context-test.h"
 #include "tests/meta-wayland-test-driver.h"
 #include "wayland/meta-wayland.h"
 #include "wayland/meta-wayland-surface.h"
@@ -248,7 +247,7 @@ toplevel_apply_limits (void)
   g_test_assert_expected_messages ();
 }
 
-void
+static void
 pre_run_wayland_tests (void)
 {
   MetaWaylandCompositor *compositor;
@@ -259,7 +258,7 @@ pre_run_wayland_tests (void)
   test_driver = meta_wayland_test_driver_new (compositor);
 }
 
-void
+static void
 init_wayland_tests (void)
 {
   g_test_add_func ("/wayland/subsurface/remap-toplevel",
@@ -273,3 +272,20 @@ init_wayland_tests (void)
   g_test_add_func ("/wayland/toplevel/apply-limits",
                    toplevel_apply_limits);
 }
+
+int
+main (int argc, char *argv[])
+{
+  g_autoptr (MetaContext) context = NULL;
+
+  context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
+                                      META_CONTEXT_TEST_FLAG_TEST_CLIENT);
+  g_assert (meta_context_configure (context, &argc, &argv, NULL));
+
+  init_wayland_tests ();
+
+  g_signal_connect (context, "before-tests",
+                    G_CALLBACK (pre_run_wayland_tests), NULL);
+
+  return meta_context_test_run_tests (META_CONTEXT_TEST (context));
+}


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