[gtk+/wip/installed-tests: 2/2] Add --enable-installed-tests, use it for reftests



commit cba235ffff664c58ac5a7456c6374d98c5917875
Author: Colin Walters <walters verbum org>
Date:   Fri May 3 09:38:59 2013 -0400

    Add --enable-installed-tests, use it for reftests
    
    See https://live.gnome.org/GnomeGoals/InstalledTests
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699601

 configure.ac                 |    6 ++++++
 tests/reftests/Makefile.am   |   34 ++++++++++++++++++++++++++++------
 tests/reftests/gtk-reftest.c |   27 +++++++++++++++++++--------
 3 files changed, 53 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d15fdbd..a77b735 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,6 +255,12 @@ AC_ARG_ENABLE(rebuilds,
               [AS_HELP_STRING([--disable-rebuilds],
                               [disable all source autogeneration rules])],,
               [enable_rebuilds=yes])
+AC_ARG_ENABLE(installed_tests,
+              AS_HELP_STRING([--enable-installed-tests],
+                             [Install test programs (default: no)]),,
+              [enable_installed_tests=no])
+AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
+
 
 AC_ARG_ENABLE(gtk2-dependency,
               [AS_HELP_STRING([--enable-gtk2-dependency],
diff --git a/tests/reftests/Makefile.am b/tests/reftests/Makefile.am
index 3d8b3b6..897a877 100644
--- a/tests/reftests/Makefile.am
+++ b/tests/reftests/Makefile.am
@@ -1,15 +1,19 @@
 include $(top_srcdir)/Makefile.decl
+NULL =
 
 TEST_PROGS += gtk-reftest
 
 check_PROGRAMS = $(TEST_PROGS)
 
+insttestdir=$(pkglibexecdir)/installed-tests
+
 gtk_reftest_CFLAGS = \
        -I$(top_srcdir)                 \
        -I$(top_builddir)/gdk           \
        -I$(top_srcdir)/gdk             \
        -DGDK_DISABLE_DEPRECATED        \
        -DGTK_DISABLE_DEPRECATED        \
+       -DINSTTESTDIR=\""$(insttestdir)"\"      \
        $(GTK_DEBUG_FLAGS)              \
        $(GTK_DEP_CFLAGS)
 
@@ -24,8 +28,11 @@ gtk_reftest_SOURCES = \
 clean-local:
        rm -rf output/ || true
 
-EXTRA_DIST += \
-       align-expand.sh \
+EXTRA_DIST = align-expand.sh \
+       border-image-repeat.sh \
+       $(NULL)
+
+testdata = \
        background-area.css \
        background-area.ref.ui \
        background-area.ui \
@@ -86,7 +93,6 @@ EXTRA_DIST += \
        border-image-gradient.ui \
        border-image-repeat.css \
        border-image-repeat.ref.ui \
-       border-image-repeat.sh \
        border-image-repeat.ui \
        border-image-url.css \
        border-image-url.ref.ui \
@@ -109,8 +115,6 @@ EXTRA_DIST += \
        box-shadow-spec-inset.css \
        box-shadow-spec-inset.ref.ui \
        box-shadow-spec-inset.ui \
-       button-wrapping.ui \
-       button-wrapping.ref.ui \
        css-match-class.css \
        css-match-class.ref.ui \
        css-match-class.ui \
@@ -272,6 +276,24 @@ EXTRA_DIST += \
        unresolvable.ref.ui \
        unresolvable.ui \
        window-default-size.ref.ui \
-       window-default-size.ui
+       window-default-size.ui \
+       $(NULL)
+
+if BUILDOPT_INSTALL_TESTS
+reftestdir = $(insttestdir)/reftests
+reftest_DATA = $(testdata)
+
+insttest_PROGRAMS = gtk-reftest
+
+reftest-%.test: %.ui Makefile
+       $(AM_V_GEN) (echo '[Test]' > $  tmp; \
+        echo 'Exec=/bin/sh -c "$(pkglibexecdir)/installed-tests/gtk-reftest -o $$(pwd) -d 
$(pkglibexecdir)/installed-tests/reftests $(notdir $<)"' >> $  tmp; \
+        echo 'Type=session' >> $  tmp; \
+        mv $  tmp $@)
+
+testmetadir = $(datadir)/installed-tests/$(PACKAGE)
+testuifiles = $(filter %.ui,$(filter-out %.ref.ui,$(testdata)))
+testmeta_DATA = $(patsubst %.ui,reftest-%.test,$(testuifiles))
+endif
 
 -include $(top_srcdir)/git.mk
diff --git a/tests/reftests/gtk-reftest.c b/tests/reftests/gtk-reftest.c
index dfa19fd..ff0bd45 100644
--- a/tests/reftests/gtk-reftest.c
+++ b/tests/reftests/gtk-reftest.c
@@ -33,10 +33,13 @@ typedef enum {
 #define GTK_STYLE_PROVIDER_PRIORITY_FORCE G_MAXUINT
 
 static char *arg_output_dir = NULL;
+static char *arg_base_dir = NULL;
 
 static const GOptionEntry test_args[] = {
   { "output",         'o', 0, G_OPTION_ARG_FILENAME, &arg_output_dir,
     "Directory to save image files to", "DIR" },
+  { "basedir",        'd', 0, G_OPTION_ARG_FILENAME, &arg_base_dir,
+    "Directory which contains tests", "DIR" },
   { NULL }
 };
 
@@ -566,6 +569,9 @@ add_tests_for_files_in_directory (GFile *dir)
 int
 main (int argc, char **argv)
 {
+  const char *basedir;
+  GFile *dir;
+  
   /* I don't want to fight fuzzy scaling algorithms in GPUs,
    * so unles you explicitly set it to something else, we
    * will use Cairo's image surface.
@@ -575,16 +581,21 @@ main (int argc, char **argv)
   if (!parse_command_line (&argc, &argv))
     return 1;
 
+  if (arg_base_dir)
+    basedir = arg_base_dir;
+  else if (g_getenv ("srcdir"))
+    basedir = g_getenv ("srcdir");
+  else
+    basedir = ".";
+
+  /* We need to ensure the process' current working directory
+   * is the same as the reftest data, because we're using the
+   * "file" property of GtkImage as a relative path in builder files.
+   */
+  chdir (basedir);
+
   if (argc < 2)
     {
-      const char *basedir;
-      GFile *dir;
-
-      if (g_getenv ("srcdir"))
-        basedir = g_getenv ("srcdir");
-      else
-        basedir = ".";
-        
       dir = g_file_new_for_path (basedir);
       
       add_tests_for_files_in_directory (dir);


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