[gimp/gimp-2-8] Bug 709878 - test-session-* skipped when xvfb-run is unavailable.



commit 373ef0b5262c995911f3d9ec34d1dd640b1c7390
Author: Jehan <jehan girinstud io>
Date:   Fri Oct 11 20:36:26 2013 +1300

    Bug 709878 - test-session-* skipped when xvfb-run is unavailable.
    
    Also add a GIMP_EXIT_TEST_SKIPPED #define, to return the SKIP exit value
    documented by automake.
    (cherry picked from commit 6ee77e5635ced9a9b48959199eca888104f020e6)

 app/tests.h                                        |   10 ++++++++++
 app/tests/test-session-2-6-compatibility.c         |   11 +++++++++++
 .../test-session-2-8-compatibility-multi-window.c  |   12 ++++++++++++
 .../test-session-2-8-compatibility-single-window.c |   11 +++++++++++
 configure.ac                                       |    1 +
 5 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/app/tests.h b/app/tests.h
index 0f783fa..c331064 100644
--- a/app/tests.h
+++ b/app/tests.h
@@ -18,6 +18,16 @@
 #ifndef __TESTS_H__
 #define __TESTS_H__
 
+/* Automake doc says:
+   "When no test protocol is in use, an exit status of 0 from a test
+   script will denote a success, an exit status of 77 a skipped test,
+   an exit status of 99 an hard error, and any other exit status will
+   denote a failure."
+
+   Unfortunately glib returns a SUCCESS when you skip tests, which is
+   not a reliable test feedback. So we hard-code the SKIPPED return
+   value. */
+#define GIMP_EXIT_TEST_SKIPPED 77
 
 Gimp * gimp_init_for_testing             (void);
 Gimp * gimp_init_for_gui_testing         (gboolean     show_gui);
diff --git a/app/tests/test-session-2-6-compatibility.c b/app/tests/test-session-2-6-compatibility.c
index 8d27a23..0333655 100644
--- a/app/tests/test-session-2-6-compatibility.c
+++ b/app/tests/test-session-2-6-compatibility.c
@@ -30,6 +30,9 @@
 #define ADD_TEST(function) \
   g_test_add_func ("/gimp-session-2-6-compatibility/" #function, function);
 
+#define SKIP_TEST(function) \
+  g_test_add_func ("/gimp-session-2-6-compatibility/subprocess/" #function, function);
+
 
 /**
  * Tests that a sessionrc and dockrc from GIMP 2.6 is loaded and
@@ -50,8 +53,16 @@ int main(int argc, char **argv)
   gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
+#ifdef HAVE_XVFB_RUN
   ADD_TEST (read_and_write_session_files);
+#else
+  SKIP_TEST (read_and_write_session_files);
+#endif
 
   /* Don't bother freeing stuff, the process is short-lived */
+#ifdef HAVE_XVFB_RUN
   return g_test_run ();
+#else
+  return GIMP_EXIT_TEST_SKIPPED;
+#endif
 }
diff --git a/app/tests/test-session-2-8-compatibility-multi-window.c 
b/app/tests/test-session-2-8-compatibility-multi-window.c
index c72398e..c46341f 100644
--- a/app/tests/test-session-2-8-compatibility-multi-window.c
+++ b/app/tests/test-session-2-8-compatibility-multi-window.c
@@ -31,6 +31,10 @@
   g_test_add_func ("/gimp-session-2-8-compatibility-multi-window/" #function, \
                    function);
 
+#define SKIP_TEST(function) \
+  g_test_add_func ("/gimp-session-2-8-compatibility-multi-window/subprocess/" #function, \
+                   function);
+
 
 /**
  * Tests that a single-window sessionrc in GIMP 2.8 format is loaded
@@ -51,8 +55,16 @@ int main(int argc, char **argv)
   gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
+#ifdef HAVE_XVFB_RUN
   ADD_TEST (read_and_write_session_files);
+#else
+  SKIP_TEST (read_and_write_session_files);
+#endif
 
   /* Don't bother freeing stuff, the process is short-lived */
+#ifdef HAVE_XVFB_RUN
   return g_test_run ();
+#else
+  return GIMP_EXIT_TEST_SKIPPED;
+#endif
 }
diff --git a/app/tests/test-session-2-8-compatibility-single-window.c 
b/app/tests/test-session-2-8-compatibility-single-window.c
index a9811d5..3f56644 100644
--- a/app/tests/test-session-2-8-compatibility-single-window.c
+++ b/app/tests/test-session-2-8-compatibility-single-window.c
@@ -31,6 +31,9 @@
   g_test_add_func ("/gimp-session-2-8-compatibility-single-window/" #function, \
                    function);
 
+#define SKIP_TEST(function) \
+  g_test_add_func ("/gimp-session-2-8-compatibility-single-window/subprocess/" #function, \
+                   function);
 
 /**
  * Tests that a multi-window sessionrc in GIMP 2.8 format is loaded
@@ -51,8 +54,16 @@ int main(int argc, char **argv)
   gimp_test_bail_if_no_display ();
   gtk_test_init (&argc, &argv, NULL);
 
+#ifdef HAVE_XVFB_RUN
   ADD_TEST (read_and_write_session_files);
+#else
+  SKIP_TEST (read_and_write_session_files);
+#endif
 
   /* Don't bother freeing stuff, the process is short-lived */
+#ifdef HAVE_XVFB_RUN
   return g_test_run ();
+#else
+  return GIMP_EXIT_TEST_SKIPPED;
+#endif
 }
diff --git a/configure.ac b/configure.ac
index bf41282..82c99a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1953,6 +1953,7 @@ if test "x$with_xvfb_run" != "xno"; then
   AC_PATH_PROG(XVFB_RUN, xvfb-run, no)
   if test "x$XVFB_RUN" != "xno"; then
     have_xvfb_run="yes"
+    AC_DEFINE(HAVE_XVFB_RUN, 1, [Define to 1 if xvfb-run is available])
   else
     have_xvfb_run="no (not found)"
   fi


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