tests/clutter: Make $DISPLAY non-optional

All our tests rely on the nested backend, which runs on top of X11, so
there is no point in having code that tries to handle not finding a
valid $DISPLAY.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
This commit is contained in:
Jonas Ådahl 2020-07-09 19:26:06 +02:00
parent 28cb025190
commit 787bc3d993

View File

@ -5,7 +5,7 @@
#include <clutter/clutter.h> #include <clutter/clutter.h>
typedef struct { typedef struct {
guint no_display : 1; gpointer dummy_field;
} ClutterTestEnvironment; } ClutterTestEnvironment;
static ClutterTestEnvironment *test_environ = NULL; static ClutterTestEnvironment *test_environ = NULL;
@ -39,33 +39,19 @@ void
clutter_test_init (int *argc, clutter_test_init (int *argc,
char ***argv) char ***argv)
{ {
gboolean no_display = FALSE; const char *display = g_getenv ("DISPLAY");
if (G_UNLIKELY (test_environ != NULL)) if (G_UNLIKELY (test_environ != NULL))
g_error ("Attempting to initialize the test suite more than once, " g_error ("Attempting to initialize the test suite more than once, "
"aborting...\n"); "aborting...\n");
#ifdef CLUTTER_WINDOWING_X11 display = g_getenv ("DISPLAY");
/* on X11 backends we need the DISPLAY environment set. if (!display || *display == '\0')
*
* check_windowing_backend() will pre-initialize the Clutter
* backend object.
*/
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
{ {
const char *display = g_getenv ("DISPLAY"); g_error ("No DISPLAY environment variable found, but we require a "
"DISPLAY set in order to run the conformance test suite.\n"
if (display == NULL || *display == '\0') "Skipping all tests.\n");
{
g_test_message ("No DISPLAY environment variable found, but we require a "
"DISPLAY set in order to run the conformance test suite.\n"
"Skipping all tests.\n");
no_display = TRUE;
goto out;
}
} }
#endif
/* we explicitly disable the synchronisation to the vertical refresh /* we explicitly disable the synchronisation to the vertical refresh
* rate, and run the master clock using a 60 fps timer instead. * rate, and run the master clock using a 60 fps timer instead.
@ -75,13 +61,11 @@ clutter_test_init (int *argc,
/* perform the actual initialization */ /* perform the actual initialization */
g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS);
out:
g_test_init (argc, argv, NULL); g_test_init (argc, argv, NULL);
g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s"); g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s");
/* our global state, accessible from each test unit */ /* our global state, accessible from each test unit */
test_environ = g_new0 (ClutterTestEnvironment, 1); test_environ = g_new0 (ClutterTestEnvironment, 1);
test_environ->no_display = no_display;
} }
/** /**
@ -119,12 +103,6 @@ clutter_test_func_wrapper (gconstpointer data_)
stage = clutter_test_get_stage (); stage = clutter_test_get_stage ();
g_assert_false (clutter_actor_is_mapped (stage)); g_assert_false (clutter_actor_is_mapped (stage));
if (test_environ->no_display)
{
g_test_skip ("No DISPLAY set");
goto out;
}
if (data->test_data != NULL) if (data->test_data != NULL)
{ {
GTestDataFunc test_func = data->test_func; GTestDataFunc test_func = data->test_func;
@ -138,7 +116,6 @@ clutter_test_func_wrapper (gconstpointer data_)
test_func (); test_func ();
} }
out:
if (data->test_notify != NULL) if (data->test_notify != NULL)
data->test_notify (data->test_data); data->test_notify (data->test_data);