[gtk+] reftests: override GSETTINGS_SCHEMA_DIR when running tests



commit d9dd7eb7576c905312cae5bc5a0b86a13d2c6465
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Sat Jul 16 11:48:32 2016 -0700

    reftests: override GSETTINGS_SCHEMA_DIR when running tests
    
    The reftest depends on a schema we install ourselves. Instruct GIO to
    look in the build directory to avoid a cyclic dep.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768930

 testsuite/reftests/Makefile.am   |   16 ++++++++++++++++
 testsuite/reftests/gtk-reftest.c |    6 ++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index 69ef0cd..068d9f8 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -464,6 +464,22 @@ EXTRA_DIST +=                      \
        reftests.test.in        \
        $(NULL)
 
+GTK_GSETTINGS_SCHEMAS = \
+       $(top_srcdir)/gtk/org.gtk.Settings.ColorChooser.gschema.xml \
+       $(top_srcdir)/gtk/org.gtk.Settings.FileChooser.gschema.xml \
+       $(NULL)
+
+BUILT_SOURCES = gschemas.compiled
+
+CLEANFILES = gschemas.compiled
+
+gschemas.compiled: $(GTK_GSETTINGS_SCHEMAS)
+       $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) \
+               $(addprefix --schema-file=,$(GTK_GSETTINGS_SCHEMAS)) \
+               --targetdir=$(builddir)
+
+all-am: gschemas.compiled
+
 if BUILDOPT_INSTALL_TESTS
 insttestdir=$(libexecdir)/installed-tests/$(PACKAGE)
 insttest_PROGRAMS = gtk-reftest
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index 193fd03..4930af8 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -58,6 +58,7 @@ parse_command_line (int *argc, char ***argv)
 {
   GError *error = NULL;
   GOptionContext *context;
+  char *schema_dir;
 
   context = g_option_context_new ("- run GTK reftests");
   g_option_context_add_main_entries (context, test_args, NULL);
@@ -71,6 +72,11 @@ parse_command_line (int *argc, char ***argv)
 
   gtk_test_init (argc, argv);
 
+  /* g_test_build_filename must be called after gtk_test_init */
+  schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL);
+  g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE);
+  g_free (schema_dir);
+
   if (g_strcmp0 (arg_direction, "rtl") == 0)
     gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
   else if (g_strcmp0 (arg_direction, "ltr") == 0)


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