mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
tests/test-runner: Port to MetaContext
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
54c9ca7d06
commit
d6ae8e7873
@ -73,8 +73,7 @@ test_client = executable('mutter-test-client',
|
|||||||
|
|
||||||
test_runner = executable('mutter-test-runner',
|
test_runner = executable('mutter-test-runner',
|
||||||
sources: [
|
sources: [
|
||||||
'test-utils.c',
|
test_context_sources,
|
||||||
'test-utils.h',
|
|
||||||
'test-runner.c',
|
'test-runner.c',
|
||||||
],
|
],
|
||||||
include_directories: tests_includepath,
|
include_directories: tests_includepath,
|
||||||
|
@ -24,12 +24,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "compositor/meta-plugin-manager.h"
|
|
||||||
#include "core/main-private.h"
|
|
||||||
#include "core/window-private.h"
|
#include "core/window-private.h"
|
||||||
#include "meta/main.h"
|
|
||||||
#include "meta/util.h"
|
#include "meta/util.h"
|
||||||
#include "meta/window.h"
|
#include "meta/window.h"
|
||||||
|
#include "tests/meta-context-test.h"
|
||||||
#include "tests/test-utils.h"
|
#include "tests/test-utils.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "wayland/meta-wayland.h"
|
#include "wayland/meta-wayland.h"
|
||||||
@ -1033,10 +1031,10 @@ typedef struct
|
|||||||
char **tests;
|
char **tests;
|
||||||
} RunTestsInfo;
|
} RunTestsInfo;
|
||||||
|
|
||||||
static gboolean
|
static int
|
||||||
run_tests (gpointer data)
|
run_tests (MetaContext *context,
|
||||||
|
RunTestsInfo *info)
|
||||||
{
|
{
|
||||||
RunTestsInfo *info = data;
|
|
||||||
int i;
|
int i;
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
|
|
||||||
@ -1048,9 +1046,7 @@ run_tests (gpointer data)
|
|||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_quit (success ? 0 : 1);
|
return success ? 0 : 1;
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@ -1124,35 +1120,26 @@ const GOptionEntry options[] = {
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
GOptionContext *ctx;
|
g_autoptr (MetaContext) context = NULL;
|
||||||
GError *error = NULL;
|
GPtrArray *tests;
|
||||||
|
RunTestsInfo info;
|
||||||
|
|
||||||
/* First parse the arguments that are passed to us */
|
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED);
|
||||||
|
|
||||||
ctx = g_option_context_new (NULL);
|
meta_context_add_option_entries (context, options, NULL);
|
||||||
g_option_context_add_main_entries (ctx, options, NULL);
|
|
||||||
|
|
||||||
if (!g_option_context_parse (ctx,
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
&argc, &argv, &error))
|
|
||||||
{
|
|
||||||
g_printerr ("%s", error->message);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_option_context_free (ctx);
|
|
||||||
|
|
||||||
test_init (&argc, &argv);
|
|
||||||
|
|
||||||
GPtrArray *tests = g_ptr_array_new ();
|
|
||||||
|
|
||||||
|
tests = g_ptr_array_new ();
|
||||||
if (all_tests)
|
if (all_tests)
|
||||||
{
|
{
|
||||||
GFile *test_dir = g_file_new_for_path (MUTTER_PKGDATADIR "/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))
|
if (!find_metatests_in_directory (test_dir, tests, &error))
|
||||||
{
|
{
|
||||||
g_printerr ("Error enumerating tests: %s\n", error->message);
|
g_printerr ("Error enumerating tests: %s\n", error->message);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1171,31 +1158,9 @@ main (int argc, char **argv)
|
|||||||
g_free (curdir);
|
g_free (curdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then initialize mutter with a different set of arguments */
|
info.tests = (char **) tests->pdata;
|
||||||
|
|
||||||
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.n_tests = tests->len;
|
info.n_tests = tests->len;
|
||||||
|
g_signal_connect (context, "run-tests", G_CALLBACK (run_tests), &info);
|
||||||
|
|
||||||
g_idle_add (run_tests, &info);
|
return meta_context_test_run_tests (META_CONTEXT_TEST (context));
|
||||||
|
|
||||||
return meta_run ();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user