[mutter] tests/test-runner: Port to MetaContext
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/test-runner: Port to MetaContext
- Date: Thu, 15 Jul 2021 12:40:54 +0000 (UTC)
commit d6ae8e7873822b93826168f6bc95995dc04cbeaf
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Mar 2 18:58:17 2021 +0100
tests/test-runner: Port to MetaContext
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
src/tests/meson.build | 3 +--
src/tests/test-runner.c | 69 ++++++++++++-------------------------------------
2 files changed, 18 insertions(+), 54 deletions(-)
---
diff --git a/src/tests/meson.build b/src/tests/meson.build
index a7c05fb715..65f4d4bb3a 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -73,8 +73,7 @@ test_client = executable('mutter-test-client',
test_runner = executable('mutter-test-runner',
sources: [
- 'test-utils.c',
- 'test-utils.h',
+ test_context_sources,
'test-runner.c',
],
include_directories: tests_includepath,
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 9064699c1f..aa83dd5570 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -24,12 +24,10 @@
#include <stdlib.h>
#include <string.h>
-#include "compositor/meta-plugin-manager.h"
-#include "core/main-private.h"
#include "core/window-private.h"
-#include "meta/main.h"
#include "meta/util.h"
#include "meta/window.h"
+#include "tests/meta-context-test.h"
#include "tests/test-utils.h"
#include "ui/ui.h"
#include "wayland/meta-wayland.h"
@@ -1033,10 +1031,10 @@ typedef struct
char **tests;
} RunTestsInfo;
-static gboolean
-run_tests (gpointer data)
+static int
+run_tests (MetaContext *context,
+ RunTestsInfo *info)
{
- RunTestsInfo *info = data;
int i;
gboolean success = TRUE;
@@ -1048,9 +1046,7 @@ run_tests (gpointer data)
success = FALSE;
}
- meta_quit (success ? 0 : 1);
-
- return FALSE;
+ return success ? 0 : 1;
}
/**********************************************************************/
@@ -1124,35 +1120,26 @@ const GOptionEntry options[] = {
int
main (int argc, char **argv)
{
- GOptionContext *ctx;
- GError *error = NULL;
-
- /* First parse the arguments that are passed to us */
-
- ctx = g_option_context_new (NULL);
- g_option_context_add_main_entries (ctx, options, NULL);
-
- if (!g_option_context_parse (ctx,
- &argc, &argv, &error))
- {
- g_printerr ("%s", error->message);
- return 1;
- }
+ g_autoptr (MetaContext) context = NULL;
+ GPtrArray *tests;
+ RunTestsInfo info;
- g_option_context_free (ctx);
+ context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED);
- test_init (&argc, &argv);
+ meta_context_add_option_entries (context, options, NULL);
- GPtrArray *tests = g_ptr_array_new ();
+ g_assert (meta_context_configure (context, &argc, &argv, NULL));
+ tests = g_ptr_array_new ();
if (all_tests)
{
GFile *test_dir = g_file_new_for_path (MUTTER_PKGDATADIR "/tests");
+ g_autoptr (GError) error = NULL;
if (!find_metatests_in_directory (test_dir, tests, &error))
{
g_printerr ("Error enumerating tests: %s\n", error->message);
- return 1;
+ return EXIT_FAILURE;
}
}
else
@@ -1171,31 +1158,9 @@ main (int argc, char **argv)
g_free (curdir);
}
- /* Then initialize mutter with a different set of arguments */
-
- char *fake_args[] = { NULL, (char *)"--wayland", (char *)"--nested" };
- fake_args[0] = argv[0];
- char **fake_argv = fake_args;
- int fake_argc = G_N_ELEMENTS (fake_args);
-
- ctx = meta_get_option_context ();
- if (!g_option_context_parse (ctx, &fake_argc, &fake_argv, &error))
- {
- g_printerr ("mutter: %s\n", error->message);
- exit (1);
- }
- g_option_context_free (ctx);
-
- meta_plugin_manager_load (test_get_plugin_name ());
-
- meta_init ();
- meta_register_with_session ();
-
- RunTestsInfo info;
- info.tests = (char **)tests->pdata;
+ info.tests = (char **) tests->pdata;
info.n_tests = tests->len;
+ g_signal_connect (context, "run-tests", G_CALLBACK (run_tests), &info);
- g_idle_add (run_tests, &info);
-
- return meta_run ();
+ return meta_context_test_run_tests (META_CONTEXT_TEST (context));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]