[glib] Some tests for gschema-compile
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Some tests for gschema-compile
- Date: Mon, 19 Apr 2010 18:20:59 +0000 (UTC)
commit 0e48b0638dd54fda1d567c294db0feeb52b324af
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Apr 19 13:14:30 2010 -0400
Some tests for gschema-compile
Mostly making sure that we produce reasonable error messages for
typical mistakes.
gio/tests/Makefile.am | 26 +++++--
gio/tests/gschema-compile.c | 81 +++++++++++++++++++-
gio/tests/schema-tests/bad-type/test.gschema.xml | 7 ++
.../schema-tests/incomplete-list/test.gschema.xml | 7 ++
.../schema-tests/missing-quotes/test.gschema.xml | 7 ++
gio/tests/schema-tests/no-default/test.gschema.xml | 6 ++
gio/tests/schema-tests/overflow/test.gschema.xml | 7 ++
.../schema-tests/wrong-category/test.gschema.xml | 7 ++
8 files changed, 139 insertions(+), 9 deletions(-)
---
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index 4163cb4..73941f6 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -154,7 +154,12 @@ EXTRA_DIST += \
org.gtk.test.gschema \
org.gtk.test.gschema.xml \
de.po \
- schema-tests/no-default/no-default.gschema.xml
+ 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
MISC_STUFF = gschemas.compiled test.mo
@@ -166,10 +171,15 @@ test.mo: de.po
gschemas.compiled:
$(top_builddir)/gio/gschema-compile --targetdir=$(abs_builddir) $(srcdir)
-DISTCLEANFILES = \
- applications/mimeinfo.cache \
- de/LC_MESSAGES/test.mo \
- test.mo \
- gsettings.store \
- gschemas.compiled \
- schema-tests/no-schema/gschemas.compiled
+DISTCLEANFILES = \
+ applications/mimeinfo.cache \
+ de/LC_MESSAGES/test.mo \
+ test.mo \
+ gsettings.store \
+ gschemas.compiled \
+ schema-tests/bad-type/gschemas.compiled \
+ schema-tests/incomplete-list/gschemas.compiled \
+ schema-tests/missing-quotes/gschemas.compiled \
+ schema-tests/no-default/gschemas.compiled \
+ schema-tests/wrong-category/gschemas.compiled \
+ schema-tests/overflow/gschemas.compiled
diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c
index 7a7a8e4..0069630 100644
--- a/gio/tests/gschema-compile.c
+++ b/gio/tests/gschema-compile.c
@@ -13,13 +13,87 @@ test_no_default (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
gchar *argv[] = { "../gschema-compile", "./schema-tests/no-default/", NULL };
- gchar *envp[] = { NULL };
+ gchar *envp[] = { NULL };
execve (argv[0], argv, envp);
}
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*<default> is required in <key>*");
}
+static void
+test_missing_quotes (void)
+{
+ g_remove ("schema-tests/missing-quotes/gschemas.compiled");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ gchar *argv[] = { "../gschema-compile", "./schema-tests/missing-quotes/", NULL };
+ gchar *envp[] = { NULL };
+ execve (argv[0], argv, envp);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*unknown keyword*");
+}
+
+static void
+test_incomplete_list (void)
+{
+ g_remove ("schema-tests/incomplete-list/gschemas.compiled");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ gchar *argv[] = { "../gschema-compile", "./schema-tests/incomplete-list/", NULL };
+ gchar *envp[] = { NULL };
+ execve (argv[0], argv, envp);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*to follow array element*");
+}
+
+static void
+test_wrong_category (void)
+{
+ g_remove ("schema-tests/wrong-category/gschemas.compiled");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ gchar *argv[] = { "../gschema-compile", "./schema-tests/wrong-category/", NULL };
+ gchar *envp[] = { NULL };
+ execve (argv[0], argv, envp);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*attribute 'l10n' invalid*");
+}
+
+static void
+test_bad_type (void)
+{
+ g_remove ("schema-tests/bad-type/gschemas.compiled");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ gchar *argv[] = { "../gschema-compile", "./schema-tests/bad-type/", NULL };
+ gchar *envp[] = { NULL };
+ execve (argv[0], argv, envp);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*invalid GVariant type string*");
+}
+
+static void
+test_overflow (void)
+{
+ g_remove ("schema-tests/overflow/gschemas.compiled");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ gchar *argv[] = { "../gschema-compile", "./schema-tests/overflow/", NULL };
+ gchar *envp[] = { NULL };
+ execve (argv[0], argv, envp);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*out of range*");
+}
int
main (int argc, char *argv[])
@@ -30,6 +104,11 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/gschema/no-default", test_no_default);
+ g_test_add_func ("/gschema/missing-quotes", test_missing_quotes);
+ g_test_add_func ("/gschema/incomplete-list", test_incomplete_list);
+ g_test_add_func ("/gschema/wrong-category", test_wrong_category);
+ g_test_add_func ("/gschema/bad-type", test_bad_type);
+ g_test_add_func ("/gschema/overflow", test_overflow);
return g_test_run ();
}
diff --git a/gio/tests/schema-tests/bad-type/test.gschema.xml b/gio/tests/schema-tests/bad-type/test.gschema.xml
new file mode 100644
index 0000000..9b74684
--- /dev/null
+++ b/gio/tests/schema-tests/bad-type/test.gschema.xml
@@ -0,0 +1,7 @@
+<schemalist>
+ <schema id="bad-type" path="/tests/">
+ <key name="test" type="-%$#*(a!">
+ <default></default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/incomplete-list/test.gschema.xml b/gio/tests/schema-tests/incomplete-list/test.gschema.xml
new file mode 100644
index 0000000..df33e84
--- /dev/null
+++ b/gio/tests/schema-tests/incomplete-list/test.gschema.xml
@@ -0,0 +1,7 @@
+<schemalist>
+ <schema id="incomplete-list" path="/tests/">
+ <key name="test" type="ai">
+ <default>[1,2,3</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/missing-quotes/test.gschema.xml b/gio/tests/schema-tests/missing-quotes/test.gschema.xml
new file mode 100644
index 0000000..4400a62
--- /dev/null
+++ b/gio/tests/schema-tests/missing-quotes/test.gschema.xml
@@ -0,0 +1,7 @@
+<schemalist>
+ <schema id="missing-quotes" path="/tests/">
+ <key name="test" type="s">
+ <default>foo</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/no-default/test.gschema.xml b/gio/tests/schema-tests/no-default/test.gschema.xml
new file mode 100644
index 0000000..5496ce3
--- /dev/null
+++ b/gio/tests/schema-tests/no-default/test.gschema.xml
@@ -0,0 +1,6 @@
+<schemalist>
+ <schema id="no-default" path="/tests/">
+ <key name="test" type="s">
+ </key>
+ </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/overflow/test.gschema.xml b/gio/tests/schema-tests/overflow/test.gschema.xml
new file mode 100644
index 0000000..19d4176
--- /dev/null
+++ b/gio/tests/schema-tests/overflow/test.gschema.xml
@@ -0,0 +1,7 @@
+<schemalist>
+ <schema id="test">
+ <key name="test" type="y">
+ <default>512</default>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/wrong-category/test.gschema.xml b/gio/tests/schema-tests/wrong-category/test.gschema.xml
new file mode 100644
index 0000000..5c1ec79
--- /dev/null
+++ b/gio/tests/schema-tests/wrong-category/test.gschema.xml
@@ -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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]