[gimp] app: Don't run UI tests when there is no DISPLAY



commit 185deee3b22d09516afadea9513cd4ec8871607c
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Oct 3 11:14:35 2010 +0200

    app: Don't run UI tests when there is no DISPLAY

 app/tests.c                         |   19 +++++++++++++++++++
 app/tests.h                         |    1 +
 app/tests/test-session-management.c |    1 +
 app/tests/test-ui.c                 |    1 +
 app/tests/test-xcf.c                |    1 +
 5 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/app/tests.c b/app/tests.c
index 90272c3..30324ef 100644
--- a/app/tests.c
+++ b/app/tests.c
@@ -17,6 +17,8 @@
 
 #include "config.h"
 
+#include <stdlib.h>
+
 #include <gtk/gtk.h>
 
 #include "gui/gui-types.h"
@@ -160,3 +162,20 @@ gimp_test_run_mainloop_until_idle (void)
 
   g_main_loop_unref (loop);
 }
+
+/**
+ * gimp_test_bail_if_no_display:
+ * @void:
+ *
+ * If no DISPLAY is set, call exit(EXIT_SUCCESS). There is no use in
+ * having UI tests failing in DISPLAY-less environments.
+ **/
+void
+gimp_test_bail_if_no_display (void)
+{
+  if (! g_getenv ("DISPLAY"))
+    {
+      g_message ("No DISPLAY set, not running UI tests\n");
+      exit (EXIT_SUCCESS);
+    }
+}
diff --git a/app/tests.h b/app/tests.h
index 7ec8608..37242ec 100644
--- a/app/tests.h
+++ b/app/tests.h
@@ -24,6 +24,7 @@ Gimp * gimp_init_for_gui_testing         (gboolean use_cpu_accel,
                                           gboolean show_gui);
 void   gimp_test_run_temp_mainloop       (guint32  running_time);
 void   gimp_test_run_mainloop_until_idle (void);
+void   gimp_test_bail_if_no_display      (void);
 
 
 #endif /* __TESTS_H__ */
diff --git a/app/tests/test-session-management.c b/app/tests/test-session-management.c
index 3c6f40e..214aa3b 100644
--- a/app/tests/test-session-management.c
+++ b/app/tests/test-session-management.c
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
   gchar             *dockrc_filename         = NULL;
   gint               result                  = 0;
 
+  gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
   /* Make sure to run this before we use any GIMP functions */
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index 8d1fe97..869a223 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -838,6 +838,7 @@ int main(int argc, char **argv)
   Gimp *gimp   = NULL;
   gint  result = -1;
 
+  gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
   gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
diff --git a/app/tests/test-xcf.c b/app/tests/test-xcf.c
index 58ff190..03764d1 100644
--- a/app/tests/test-xcf.c
+++ b/app/tests/test-xcf.c
@@ -968,6 +968,7 @@ main (int    argc,
 {
   int result;
 
+  gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
   gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",



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