[gimp] tests: build the test icon theme for all platforms.



commit b1fc539f6ca1fe66da7792d1d2985da5b16a51f2
Author: Jehan <jehan girinstud io>
Date:   Fri Aug 15 03:25:43 2014 +0000

    tests: build the test icon theme for all platforms.
    
    In particular, we were not building these for win32, which has no
    symbolic link concept. So let's use $(LN_S) defined by autoconf for this
    purpose, as it will copy files for platforms without ln support.
    Moreover this way, we don't create one such folder for each and every
    test run and fill up the tmp directory with countless directories, that
    we never clean up.
    On Win32, this fixes 3 tests which were failing because of the missing
    icons.

 app/tests.c           |   59 +-----------------------------------------------
 app/tests/.gitignore  |    1 +
 app/tests/Makefile.am |   11 ++++++++-
 configure.ac          |    1 +
 4 files changed, 14 insertions(+), 58 deletions(-)
---
diff --git a/app/tests.c b/app/tests.c
index 764438a..bfb5b4b 100644
--- a/app/tests.c
+++ b/app/tests.c
@@ -82,71 +82,18 @@ gimp_init_for_testing (void)
 
 #ifndef GIMP_CONSOLE_COMPILATION
 
-#ifndef G_OS_WIN32
-
 static void
 gimp_init_icon_theme_for_testing (void)
 {
-  const gchar *top_srcdir = g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR");
   gchar       *icon_root;
-  gchar       *link_name;
-  gchar       *link_target;
-  gint         i;
-
-  static const gchar *sizes[] = { "12x12", "16x16", "18x18", "20x20", "22x22",
-                                  "24x24", "32x32", "48x48", "64x64" };
-
-  if (! top_srcdir)
-    {
-      g_printerr ("*\n"
-                  "*  The env var GIMP_TESTING_ABS_TOP_SRCDIR is not set,\n"
-                  "*  you are probably running in a debugger.\n"
-                  "*  Set it manually, e.g.:\n"
-                  "*\n"
-                  "*    set env GIMP_TESTING_ABS_TOP_SRCDIR=%s/source/gimp\n"
-                  "*\n",
-                  g_get_home_dir ());
-      return;
-    }
-
-  icon_root = g_dir_make_tmp ("gimp-test-icon-theme-XXXXXX", NULL);
-  if (! icon_root)
-    return;
-
-  for (i = 0; i < G_N_ELEMENTS (sizes); i++)
-    {
-      gchar *icon_dir;
-
-      icon_dir = g_build_filename (icon_root, "hicolor", sizes[i], NULL);
-      g_mkdir_with_parents (icon_dir, 0700);
-
-      link_name   = g_build_filename (icon_dir, "apps", NULL);
-      link_target = g_build_filename (top_srcdir, "icons", sizes[i] + 3, NULL);
-
-      symlink (link_target, link_name);
-
-      g_free (link_target);
-      g_free (link_name);
-
-      g_free (icon_dir);
-    }
-
-  link_name   = g_build_filename (icon_root, "hicolor", "index.theme", NULL);
-  link_target = g_build_filename (top_srcdir, "icons", "index.theme", NULL);
-
-  symlink (link_target, link_name);
-
-  g_free (link_target);
-  g_free (link_name);
 
+  icon_root = g_test_build_filename (G_TEST_BUILT, "gimp-test-icon-theme", NULL);
   gtk_icon_theme_prepend_search_path (gtk_icon_theme_get_default (),
                                       icon_root);
-
   g_free (icon_root);
+  return;
 }
 
-#endif /* G_OS_WIN32 */
-
 static Gimp *
 gimp_init_for_gui_testing_internal (gboolean     show_gui,
                                     const gchar *gimprc)
@@ -170,9 +117,7 @@ gimp_init_for_gui_testing_internal (gboolean     show_gui,
   gimp_load_config (gimp, gimprc, NULL);
   gimp_gegl_init (gimp);
   gui_init (gimp, TRUE);
-#ifndef G_OS_WIN32
   gimp_init_icon_theme_for_testing ();
-#endif
   gimp_initialize (gimp, gimp_status_func_dummy);
   gimp_restore (gimp, gimp_status_func_dummy);
 
diff --git a/app/tests/.gitignore b/app/tests/.gitignore
index 481b9a2..22c5bc6 100644
--- a/app/tests/.gitignore
+++ b/app/tests/.gitignore
@@ -19,3 +19,4 @@ test-window-management*
 test-xcf*
 /*.trs
 /*.log
+/gimp-test-icon-theme
diff --git a/app/tests/Makefile.am b/app/tests/Makefile.am
index 13ccd03..4fb1f85 100644
--- a/app/tests/Makefile.am
+++ b/app/tests/Makefile.am
@@ -33,7 +33,7 @@ TESTS = \
 EXTRA_PROGRAMS = $(TESTS)
 CLEANFILES = $(EXTRA_PROGRAMS)
 
-$(TESTS): gimpdir-output
+$(TESTS): gimpdir-output gimp-test-icon-theme
 
 noinst_LIBRARIES = libgimpapptestutils.a
 libgimpapptestutils_a_SOURCES = \
@@ -137,5 +137,14 @@ gimpdir-output:
        mkdir -p gimpdir-output/patterns
        mkdir -p gimpdir-output/gradients
 
+gimp-test-icon-theme:
+       mkdir -p $$(echo $$(find ../../icons/ -name [0-9][0-9] -type d | sed 's  */\([0-9][0-9]\)$$ 
gimp-test-icon-theme/hicolor/\1x\1@'))
+       for dir in $$(echo $$(find ../../icons/ -name [0-9][0-9] -type d | sed 's  */\([0-9][0-9]\)$$ \1@')); 
do \
+               (cd gimp-test-icon-theme/hicolor/$${dir}x$${dir}/ && \
+               $(LN_S) ../../../../../icons/$${dir} apps); \
+       done
+       (cd gimp-test-icon-theme/hicolor && $(LN_S) ../../../../icons/index.theme index.theme)
+
 clean-local:
        rm -rf gimpdir-output
+       rm -fr gimp-test-icon-theme
diff --git a/configure.ac b/configure.ac
index b21c2b5..261ff43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -323,6 +323,7 @@ AC_SUBST(WINDRES)
 # Checks for programs.
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
+AC_PROG_LN_S
 
 # Large file support for the swap file
 AC_SYS_LARGEFILE


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