summaryrefslogtreecommitdiff
path: root/gio/tests/gsettings.c
diff options
context:
space:
mode:
Diffstat (limited to 'gio/tests/gsettings.c')
-rw-r--r--gio/tests/gsettings.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 313523453..61e13e8fe 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -8,6 +8,7 @@
#include "testenum.h"
+static const gchar *datapath;
static gboolean backend_set;
/* These tests rely on the schemas in org.gtk.test.gschema.xml
@@ -2247,40 +2248,58 @@ main (int argc, char *argv[])
setlocale (LC_ALL, "");
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
if (!g_test_subprocess ())
{
+ const gchar *glib_mkenums;
+ const gchar *glib_compile_schemas;
+ gchar *cmdline;
+
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
- g_setenv ("XDG_DATA_DIRS", ".", TRUE);
+ g_setenv ("XDG_DATA_DIRS", datapath, TRUE);
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE);
if (!backend_set)
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
- g_remove ("org.gtk.test.enums.xml");
- g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
- "--template " SRCDIR "/enums.xml.template "
- SRCDIR "/testenum.h",
- &enums, NULL, &result, NULL));
+ if (g_getenv ("GLIB_MKENUMS"))
+ glib_mkenums = g_getenv ("GLIB_MKENUMS");
+ else
+ glib_mkenums = "glib-mkenums";
+
+ cmdline = g_strdup_printf ("%s --template %s/enums.xml.template %s/testenum.h", glib_mkenums, datapath, datapath);
+
+ g_assert (g_spawn_command_line_sync (cmdline, &enums, NULL, &result, NULL));
g_assert (result == 0);
g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL));
g_free (enums);
- g_remove ("gschemas.compiled");
- g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. "
- "--schema-file=org.gtk.test.enums.xml "
- "--schema-file=" SRCDIR "/org.gtk.test.gschema.xml",
- NULL, NULL, &result, NULL));
+ g_free (cmdline);
+
+ if (g_getenv ("GLIB_COMPILE_SCHEMAS"))
+ glib_compile_schemas = g_getenv ("GLIB_COMPILE_SCHEMAS");
+ else
+ glib_compile_schemas = "glib-compile-schemas";
+
+ cmdline = g_strdup_printf ("%s --targetdir=. --schema-file=org.gtk.test.enums.xml --schema-file=%s/org.gtk.test.gschema.xml", glib_compile_schemas, datapath);
+ g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, &result, NULL));
g_assert (result == 0);
+ g_free (cmdline);
- g_remove ("schema-source/gschemas.compiled");
g_mkdir ("schema-source", 0777);
- g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=schema-source "
- "--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
- NULL, NULL, &result, NULL));
+ g_remove ("schema-source/gschemas.compiled");
+
+ cmdline = g_strdup_printf ("%s --targetdir=schema-source --schema-file=%s/org.gtk.schemasourcecheck.gschema.xml", glib_compile_schemas, datapath);
+ g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, &result, NULL));
g_assert (result == 0);
+ g_free (cmdline);
}
g_test_add_func ("/gsettings/basic", test_basic);