GSettings tests: reverse installed test complexity

Remove the complications that were introduced in an attempt to make the
gsettings and gschema-compile tests function as installed tests.  These
tests are designed (in large part for gsettings and entirely for
gschema-compile) to test the in-tree tools and should not be testing the
system versions.

In the future we may want to move the use of the in-tree tools from the
gsettings testcase into the Makefile and install the resulting files,
allowing this testcase to run against those files, installed.
This commit is contained in:
Ryan Lortie 2013-05-31 22:33:22 -04:00
parent f9eb9eed10
commit e042db0f83
2 changed files with 17 additions and 38 deletions

View File

@ -5,8 +5,6 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gstdio.h> #include <gstdio.h>
const gchar *glib_compile_schemas;
typedef struct { typedef struct {
const gchar *name; const gchar *name;
const gchar *opt; const gchar *opt;
@ -20,7 +18,7 @@ test_schema_do_compile (gpointer data)
gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL); gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL); gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
gchar *argv[] = { gchar *argv[] = {
(gchar*)glib_compile_schemas, "../glib-compile-schemas",
"--strict", "--strict",
"--dry-run", "--dry-run",
"--schema-file", path, "--schema-file", path,
@ -141,11 +139,6 @@ main (int argc, char *argv[])
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
if (g_getenv ("GLIB_COMPILE_SCHEMAS"))
glib_compile_schemas = g_getenv ("GLIB_COMPILE_SCHEMAS");
else
glib_compile_schemas = "/usr/bin/glib-compile-schemas";
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
for (i = 0; i < G_N_ELEMENTS (tests); ++i) for (i = 0; i < G_N_ELEMENTS (tests); ++i)

View File

@ -2245,50 +2245,36 @@ main (int argc, char *argv[])
if (!g_test_subprocess ()) if (!g_test_subprocess ())
{ {
const gchar *glib_mkenums;
const gchar *glib_compile_schemas;
gchar *cmdline;
backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL; backend_set = g_getenv ("GSETTINGS_BACKEND") != NULL;
g_setenv ("XDG_DATA_DIRS", g_test_get_dir (G_TEST_DIST), TRUE); g_setenv ("XDG_DATA_DIRS", ".", TRUE);
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE); g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE);
if (!backend_set) if (!backend_set)
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE); g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
if (g_getenv ("GLIB_MKENUMS")) g_remove ("org.gtk.test.enums.xml");
glib_mkenums = g_getenv ("GLIB_MKENUMS"); g_assert (g_spawn_command_line_sync ("../../gobject/glib-mkenums "
else "--template " SRCDIR "/enums.xml.template "
glib_mkenums = "glib-mkenums"; SRCDIR "/testenum.h",
&enums, NULL, &result, NULL));
cmdline = g_strdup_printf ("%s --template %s/enums.xml.template %s/testenum.h", glib_mkenums,
g_test_get_dir (G_TEST_DIST), g_test_get_dir (G_TEST_DIST));
g_assert (g_spawn_command_line_sync (cmdline, &enums, NULL, &result, NULL));
g_assert (result == 0); g_assert (result == 0);
g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL)); g_assert (g_file_set_contents ("org.gtk.test.enums.xml", enums, -1, NULL));
g_free (enums); g_free (enums);
g_free (cmdline); g_remove ("gschemas.compiled");
g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=. "
if (g_getenv ("GLIB_COMPILE_SCHEMAS")) "--schema-file=org.gtk.test.enums.xml "
glib_compile_schemas = g_getenv ("GLIB_COMPILE_SCHEMAS"); "--schema-file=" SRCDIR "/org.gtk.test.gschema.xml",
else NULL, NULL, &result, NULL));
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, g_test_get_dir (G_TEST_DIST));
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, &result, NULL));
g_assert (result == 0); g_assert (result == 0);
g_free (cmdline);
g_mkdir ("schema-source", 0777);
g_remove ("schema-source/gschemas.compiled"); g_remove ("schema-source/gschemas.compiled");
g_mkdir ("schema-source", 0777);
cmdline = g_strdup_printf ("%s --targetdir=schema-source --schema-file=%s/org.gtk.schemasourcecheck.gschema.xml", glib_compile_schemas, g_test_get_dir (G_TEST_DIST)); g_assert (g_spawn_command_line_sync ("../glib-compile-schemas --targetdir=schema-source "
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, &result, NULL)); "--schema-file=" SRCDIR "/org.gtk.schemasourcecheck.gschema.xml",
NULL, NULL, &result, NULL));
g_assert (result == 0); g_assert (result == 0);
g_free (cmdline);
} }
g_test_add_func ("/gsettings/basic", test_basic); g_test_add_func ("/gsettings/basic", test_basic);