summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2014-04-02 19:25:55 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2014-04-02 19:25:55 +0100
commitf9d99d1c4e573d08bdada42c0b70c984476c9541 (patch)
treefa4adfd7a7f80d2eabd07f523730c653923211af
parentf065a34e4698af8e4b04a939c077d348e5294236 (diff)
downloadclutter-f9d99d1c4e573d08bdada42c0b70c984476c9541.tar.gz
test-utils: Skip tests if no DISPLAY is set
Instead of just bailing out when initializing the test suite, we can do a much better job and skip all the tests. This means that the TAP driver will work correctly instead of dying a horrible death, and we get a nice report with a proper cause of the test skipping.
-rw-r--r--clutter/clutter-test-utils.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/clutter/clutter-test-utils.c b/clutter/clutter-test-utils.c
index 415e222e7..a5f2f7bc2 100644
--- a/clutter/clutter-test-utils.c
+++ b/clutter/clutter-test-utils.c
@@ -15,6 +15,8 @@
typedef struct {
ClutterActor *stage;
+
+ guint no_display : 1;
} ClutterTestEnvironment;
static ClutterTestEnvironment *test_environ = NULL;
@@ -32,6 +34,8 @@ void
clutter_test_init (int *argc,
char ***argv)
{
+ gboolean no_display = FALSE;
+
if (G_UNLIKELY (test_environ != NULL))
g_error ("Attempting to initialize the test suite more than once, "
"aborting...\n");
@@ -48,9 +52,12 @@ clutter_test_init (int *argc,
if (display == NULL || *display == '\0')
{
- g_print ("No DISPLAY environment variable found, but we require a "
- "DISPLAY set in order to run the conformance test suite.");
- exit (0);
+ 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
@@ -60,14 +67,16 @@ clutter_test_init (int *argc,
*/
_clutter_set_sync_to_vblank (FALSE);
- g_test_init (argc, argv, NULL);
- g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s");
-
/* perform the actual initialization */
g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS);
+out:
+ g_test_init (argc, argv, NULL);
+ g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s");
+
/* our global state, accessible from each test unit */
test_environ = g_new0 (ClutterTestEnvironment, 1);
+ test_environ->no_display = no_display;
}
/**
@@ -110,6 +119,12 @@ clutter_test_func_wrapper (gconstpointer data_)
/* ensure that the previous test state has been cleaned up */
g_assert_null (test_environ->stage);
+ if (test_environ->no_display)
+ {
+ g_test_skip ("No DISPLAY set");
+ goto out;
+ }
+
if (data->test_data != NULL)
{
GTestDataFunc test_func = data->test_func;
@@ -123,6 +138,7 @@ clutter_test_func_wrapper (gconstpointer data_)
test_func ();
}
+out:
if (data->test_notify != NULL)
data->test_notify (data->test_data);