15 test_schema_do_compile (gpointer data)
17 SchemaTest *test = (SchemaTest *) data;
18 gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
19 gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
21 "../glib-compile-schemas",
24 "--schema-file", path,
28 gchar *envp[] = { NULL };
30 execve (argv[0], argv, envp);
31 g_assert_not_reached ();
35 test_schema (gpointer data)
37 SchemaTest *test = (SchemaTest *) data;
40 child_name = g_strdup_printf ("/gschema/%s%s/subprocess/do_compile", test->name, test->opt ? "/opt" : "");
41 g_test_trap_subprocess (child_name, 0, 0);
46 g_test_trap_assert_failed ();
47 g_test_trap_assert_stderr (test->err);
50 g_test_trap_assert_passed();
53 static const SchemaTest tests[] = {
54 { "no-default", NULL, "*<default> is required in <key>*" },
55 { "missing-quotes", NULL, "*unknown keyword*" },
56 { "incomplete-list", NULL, "*to follow array element*" },
57 { "wrong-category", NULL, "*unsupported l10n category*" },
58 { "bad-type", NULL, "*invalid GVariant type string*" },
59 { "overflow", NULL, "*out of range*" },
60 { "range-wrong-type", NULL, "*<range> not allowed for keys of type*" },
61 { "range-missing-min", NULL, NULL },
62 { "range-missing-max", NULL, NULL },
63 { "default-out-of-range", NULL, "*<default> is not contained in the specified range*" },
64 { "choices-wrong-type", NULL, "*<choices> not allowed for keys of type*" },
65 { "choice-missing-value", NULL, "*element 'choice' requires attribute 'value'*" },
66 { "default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
67 { "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
68 { "bad-key", NULL, "*invalid name*" },
69 { "invalid-path", NULL, "*must begin and end with a slash*" },
70 { "bad-key", "--allow-any-name", NULL },
71 { "bad-key2", NULL, "*invalid name*" },
72 { "bad-key2", "--allow-any-name", NULL },
73 { "bad-key3", NULL, "*invalid name*" },
74 { "bad-key3", "--allow-any-name", NULL },
75 { "bad-key4", NULL, "*invalid name*" },
76 { "bad-key4", "--allow-any-name", NULL },
77 { "empty-key", NULL, "*empty names*" },
78 { "empty-key", "--allow-any-name", "*empty names*" },
79 { "enum", NULL, NULL },
80 { "enum-with-aliases", NULL, NULL },
81 { "enum-with-invalid-alias", NULL, "*'banger' is not in enumerated type*" },
82 { "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
83 { "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
84 { "enum-with-repeated-value", NULL, "*value='1' already specified*" },
85 { "enum-with-chained-alias", NULL, "*'sausages' is not in enumerated type*" },
86 { "enum-with-shadow-alias", NULL, "*'mash' is already a member of the enum*" },
87 { "enum-with-choice", NULL, "*<choices> cannot be specified*" },
88 { "enum-with-bad-default", NULL, "*<default> is not a valid member*" },
89 { "choice", NULL, NULL },
90 { "choice-upside-down", NULL, NULL },
91 { "bad-choice", NULL, "*<default> contains string not in <choices>*" },
92 { "choice-bad", NULL, "*<default> contains string not in <choices>*" },
93 { "choice-badtype", NULL, "*<choices> not allowed for keys of type 'i'*" },
94 { "bare-alias", NULL, "*enumerated or flags types or after <choices>*" },
95 { "choice-alias", NULL, NULL },
96 { "default-in-aliases", NULL, "*<default> contains string not in <choices>*" },
97 { "choice-invalid-alias", NULL, "*'befor' is not in <choices>*" },
98 { "choice-shadowed-alias", NULL, "*given when <choice value='before'/> was already*" },
99 { "range", NULL, NULL },
100 { "range-badtype", NULL, "*<range> not allowed for keys of type 's'*" },
101 { "range-low-default", NULL, "*<default> is not contained in the specified range*" },
102 { "range-high-default", NULL, "*<default> is not contained in the specified range*" },
103 { "range-default-low", NULL, "*<default> is not contained in the specified range*" },
104 { "range-default-high", NULL, "*<default> is not contained in the specified range*" },
105 { "range-parse-error", NULL, "*invalid character in number*" },
106 { "from-docs", NULL, NULL },
107 { "extending", NULL, NULL },
108 { "extend-missing", NULL, "*extends not yet existing schema*" },
109 { "extend-nonlist", NULL, "*which is not a list*" },
110 { "extend-self", NULL, "*not yet existing*" },
111 { "extend-wrong-list-indirect", NULL, "*'y' does not extend 'x'*" },
112 { "extend-wrong-list", NULL, "*'y' does not extend 'x'*" },
113 { "key-in-list-indirect", NULL, "*cannot add keys to a 'list*" },
114 { "key-in-list", NULL, "*cannot add keys to a 'list*" },
115 { "list-of-missing", NULL, "*is list of not yet existing schema*" },
116 { "extend-and-shadow", NULL, "*shadows*use <override>*" },
117 { "extend-and-shadow-indirect", NULL, "*shadows*use <override>*" },
118 { "override", NULL, NULL },
119 { "override-missing", NULL, "*no <key name='bar'> to override*" },
120 { "override-range-error", NULL, "*<override> is not contained in the specified range*"},
121 { "override-then-key", NULL, "*shadows <key name='foo'> in <schema id='base'>*" },
122 { "override-twice", NULL, "*<override name='foo'> already specified*" },
123 { "override-type-error", NULL, "*invalid character in number*" },
124 { "flags-aliased-default", NULL, "*<default> * not in the specified flags type*" },
125 { "flags-bad-default", NULL, "*<default> * not in the specified flags type*" },
126 { "flags-more-than-one-bit", NULL, "*flags values must have at most 1 bit set*" },
127 { "flags-with-enum-attr", NULL, "*<enum id='flags'> not (yet) defined*" },
128 { "flags-with-enum-tag", NULL, "*<flags id='flags'> not (yet) defined*" },
129 { "inherit-gettext-domain", NULL, NULL },
130 { "range-type-test", NULL, NULL },
131 { "cdata", NULL, NULL }
136 main (int argc, char *argv[])
140 setlocale (LC_ALL, "");
142 g_test_init (&argc, &argv, NULL);
144 for (i = 0; i < G_N_ELEMENTS (tests); ++i)
148 name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
149 g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
152 name = g_strdup_printf ("/gschema/%s%s/subprocess/do_compile", tests[i].name, tests[i].opt ? "/opt" : "");
153 g_test_add_data_func (name, &tests[i], (gpointer) test_schema_do_compile);
157 return g_test_run ();