mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-23 22:16:16 +01:00
Simplify gschema-compile test suite
Add --one-schema-file option to gschema-compile to allow easier test setup. Simplify the test setup. Bug #616276.
This commit is contained in:
parent
463203ee0a
commit
afff087785
@ -492,9 +492,16 @@ main (int argc, char **argv)
|
||||
gchar *srcdir;
|
||||
gchar *targetdir = NULL;
|
||||
gchar *target;
|
||||
gboolean dry_run = FALSE;
|
||||
gchar *one_schema_file = NULL;
|
||||
GOptionContext *context;
|
||||
GOptionEntry entries[] = {
|
||||
{ "targetdir", 0, 0, G_OPTION_ARG_FILENAME, &targetdir, N_("where to store the gschemas.compiled file"), N_("DIRECTORY") },
|
||||
{ "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Do not write the gschema.compiled file"), NULL },
|
||||
|
||||
/* These options are only for use in the gschema-compile tests */
|
||||
{ "one-schema-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &one_schema_file, NULL, NULL },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -515,7 +522,9 @@ main (int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc != 2)
|
||||
g_option_context_free (context);
|
||||
|
||||
if (!one_schema_file && argc != 2)
|
||||
{
|
||||
fprintf (stderr, _("You should give exactly one directory name\n"));
|
||||
return 1;
|
||||
@ -528,36 +537,43 @@ main (int argc, char **argv)
|
||||
|
||||
target = g_build_filename (targetdir, "gschemas.compiled", NULL);
|
||||
|
||||
dir = g_dir_open (srcdir, 0, &error);
|
||||
if (dir == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
files = g_ptr_array_new ();
|
||||
while ((file = g_dir_read_name (dir)) != NULL)
|
||||
if (one_schema_file)
|
||||
{
|
||||
if (g_str_has_suffix (file, ".gschema.xml"))
|
||||
{
|
||||
g_ptr_array_add (files, g_build_filename (srcdir, file, NULL));
|
||||
}
|
||||
g_ptr_array_add (files, one_schema_file);
|
||||
}
|
||||
|
||||
if (files->len == 0)
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("No schema files found\n"));
|
||||
return 1;
|
||||
dir = g_dir_open (srcdir, 0, &error);
|
||||
if (dir == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((file = g_dir_read_name (dir)) != NULL)
|
||||
{
|
||||
if (g_str_has_suffix (file, ".gschema.xml"))
|
||||
g_ptr_array_add (files, g_build_filename (srcdir, file, NULL));
|
||||
}
|
||||
|
||||
if (files->len == 0)
|
||||
{
|
||||
fprintf (stderr, _("No schema files found\n"));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_add (files, NULL);
|
||||
|
||||
if (!(table = parse_gschema_files ((gchar **) files->pdata, byteswap, &error)) ||
|
||||
!gvdb_table_write_contents (table, target, byteswap, &error))
|
||||
(!dry_run && !gvdb_table_write_contents (table, target, byteswap, &error)))
|
||||
{
|
||||
fprintf (stderr, "%s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_free (target);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,16 +150,16 @@ gsettings_LDADD = $(progs_ldadd)
|
||||
gschema_compile_SOURCES = gschema-compile.c
|
||||
gschema_compile_LDADD = $(progs_ldadd)
|
||||
|
||||
EXTRA_DIST += \
|
||||
org.gtk.test.gschema \
|
||||
org.gtk.test.gschema.xml \
|
||||
de.po \
|
||||
schema-tests/bad-type/test.gschema.xml \
|
||||
schema-tests/incomplete-list/test.gschema.xml \
|
||||
schema-tests/missing-quotes/test.gschema.xml \
|
||||
schema-tests/no-default/test.gschema.xml \
|
||||
schema-tests/wrong-category/test.gschema.xml \
|
||||
schema-tests/overflow/test.gschema.xml
|
||||
EXTRA_DIST += \
|
||||
org.gtk.test.gschema \
|
||||
org.gtk.test.gschema.xml \
|
||||
de.po \
|
||||
schema-tests/bad-type.gschema.xml \
|
||||
schema-tests/incomplete-list.gschema.xml \
|
||||
schema-tests/missing-quotes.gschema.xml \
|
||||
schema-tests/no-default.gschema.xml \
|
||||
schema-tests/wrong-category.gschema.xml \
|
||||
schema-tests/overflow.gschema.xml
|
||||
|
||||
MISC_STUFF = gschemas.compiled test.mo
|
||||
|
||||
|
7
gio/tests/schema-tests/bad-type.gschema.xml
Normal file
7
gio/tests/schema-tests/bad-type.gschema.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<schemalist>
|
||||
<schema id="bad-type" path="/tests/">
|
||||
<key name="test" type="-%$#*(a!">
|
||||
<default></default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
7
gio/tests/schema-tests/incomplete-list.gschema.xml
Normal file
7
gio/tests/schema-tests/incomplete-list.gschema.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<schemalist>
|
||||
<schema id="incomplete-list" path="/tests/">
|
||||
<key name="test" type="ai">
|
||||
<default>[1,2,3</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
7
gio/tests/schema-tests/missing-quotes.gschema.xml
Normal file
7
gio/tests/schema-tests/missing-quotes.gschema.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<schemalist>
|
||||
<schema id="missing-quotes" path="/tests/">
|
||||
<key name="test" type="s">
|
||||
<default>foo</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
6
gio/tests/schema-tests/no-default.gschema.xml
Normal file
6
gio/tests/schema-tests/no-default.gschema.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<schemalist>
|
||||
<schema id="no-default" path="/tests/">
|
||||
<key name="test" type="s">
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
7
gio/tests/schema-tests/overflow.gschema.xml
Normal file
7
gio/tests/schema-tests/overflow.gschema.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<schemalist>
|
||||
<schema id="test">
|
||||
<key name="test" type="y">
|
||||
<default>512</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
7
gio/tests/schema-tests/wrong-category.gschema.xml
Normal file
7
gio/tests/schema-tests/wrong-category.gschema.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<schemalist>
|
||||
<schema id="wrong-category" path="/tests/" gettext-domain="test">
|
||||
<key name="test" type="s" l10n="not-a-category">
|
||||
<default>'foo'</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
Loading…
Reference in New Issue
Block a user