]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qapi-schema/meson.build
tests/qapi-schema: Rename pragma-*-crap to pragma-value-not-*
[mirror_qemu.git] / tests / qapi-schema / meson.build
1 test_env = environment()
2 test_env.set('PYTHONPATH', meson.source_root() / 'scripts')
3 test_env.set('PYTHONIOENCODING', 'utf-8')
4
5 schemas = [
6 'alternate-any.json',
7 'alternate-array.json',
8 'alternate-base.json',
9 'alternate-branch-if-invalid.json',
10 'alternate-clash.json',
11 'alternate-conflict-dict.json',
12 'alternate-conflict-enum-bool.json',
13 'alternate-conflict-enum-int.json',
14 'alternate-conflict-string.json',
15 'alternate-conflict-bool-string.json',
16 'alternate-conflict-num-string.json',
17 'alternate-empty.json',
18 'alternate-invalid-dict.json',
19 'alternate-nested.json',
20 'alternate-unknown.json',
21 'args-alternate.json',
22 'args-any.json',
23 'args-array-empty.json',
24 'args-array-unknown.json',
25 'args-bad-boxed.json',
26 'args-boxed-anon.json',
27 'args-boxed-string.json',
28 'args-int.json',
29 'args-invalid.json',
30 'args-member-array-bad.json',
31 'args-member-case.json',
32 'args-member-unknown.json',
33 'args-name-clash.json',
34 'args-union.json',
35 'args-unknown.json',
36 'bad-base.json',
37 'bad-data.json',
38 'bad-ident.json',
39 'bad-if.json',
40 'bad-if-empty.json',
41 'bad-if-empty-list.json',
42 'bad-if-list.json',
43 'bad-type-bool.json',
44 'bad-type-dict.json',
45 'bad-type-int.json',
46 'base-cycle-direct.json',
47 'base-cycle-indirect.json',
48 'command-int.json',
49 'comments.json',
50 'doc-bad-alternate-member.json',
51 'doc-bad-boxed-command-arg.json',
52 'doc-bad-command-arg.json',
53 'doc-bad-enum-member.json',
54 'doc-bad-event-arg.json',
55 'doc-bad-feature.json',
56 'doc-bad-indent.json',
57 'doc-bad-section.json',
58 'doc-bad-symbol.json',
59 'doc-bad-union-member.json',
60 'doc-before-include.json',
61 'doc-before-pragma.json',
62 'doc-duplicated-arg.json',
63 'doc-duplicated-return.json',
64 'doc-duplicated-since.json',
65 'doc-empty-arg.json',
66 'doc-empty-section.json',
67 'doc-empty-symbol.json',
68 'doc-good.json',
69 'doc-interleaved-section.json',
70 'doc-invalid-end.json',
71 'doc-invalid-end2.json',
72 'doc-invalid-return.json',
73 'doc-invalid-section.json',
74 'doc-invalid-start.json',
75 'doc-missing-colon.json',
76 'doc-missing-expr.json',
77 'doc-missing-space.json',
78 'doc-missing.json',
79 'doc-no-symbol.json',
80 'doc-undoc-feature.json',
81 'double-type.json',
82 'duplicate-key.json',
83 'empty.json',
84 'enum-bad-member.json',
85 'enum-bad-name.json',
86 'enum-bad-prefix.json',
87 'enum-clash-member.json',
88 'enum-dict-member-unknown.json',
89 'enum-if-invalid.json',
90 'enum-int-member.json',
91 'enum-member-case.json',
92 'enum-missing-data.json',
93 'enum-wrong-data.json',
94 'event-boxed-empty.json',
95 'event-case.json',
96 'event-member-invalid-dict.json',
97 'event-nest-struct.json',
98 'features-bad-type.json',
99 'features-deprecated-type.json',
100 'features-duplicate-name.json',
101 'features-if-invalid.json',
102 'features-missing-name.json',
103 'features-name-bad-type.json',
104 'features-no-list.json',
105 'features-unknown-key.json',
106 'flat-union-array-branch.json',
107 'flat-union-bad-base.json',
108 'flat-union-bad-discriminator.json',
109 'flat-union-base-any.json',
110 'flat-union-base-union.json',
111 'flat-union-clash-member.json',
112 'flat-union-discriminator-bad-name.json',
113 'flat-union-empty.json',
114 'flat-union-inline-invalid-dict.json',
115 'flat-union-int-branch.json',
116 'flat-union-invalid-branch-key.json',
117 'flat-union-invalid-discriminator.json',
118 'flat-union-invalid-if-discriminator.json',
119 'flat-union-no-base.json',
120 'flat-union-optional-discriminator.json',
121 'flat-union-string-discriminator.json',
122 'funny-char.json',
123 'funny-word.json',
124 'ident-with-escape.json',
125 'include-before-err.json',
126 'include-cycle.json',
127 'include-extra-junk.json',
128 'include-nested-err.json',
129 'include-no-file.json',
130 'include-non-file.json',
131 'include-repetition.json',
132 'include-self-cycle.json',
133 'include-simple.json',
134 'indented-expr.json',
135 'leading-comma-list.json',
136 'leading-comma-object.json',
137 'missing-colon.json',
138 'missing-comma-list.json',
139 'missing-comma-object.json',
140 'missing-type.json',
141 'nested-struct-data.json',
142 'nested-struct-data-invalid-dict.json',
143 'non-objects.json',
144 'oob-coroutine.json',
145 'oob-test.json',
146 'allow-preconfig-test.json',
147 'pragma-extra-junk.json',
148 'pragma-non-dict.json',
149 'pragma-unknown.json',
150 'pragma-value-not-bool.json',
151 'pragma-value-not-list-of-str.json',
152 'pragma-value-not-list.json',
153 'qapi-schema-test.json',
154 'quoted-structural-chars.json',
155 'redefined-command.json',
156 'redefined-event.json',
157 'redefined-predefined.json',
158 'redefined-type.json',
159 'reserved-command-q.json',
160 'reserved-enum-q.json',
161 'reserved-member-has.json',
162 'reserved-member-q.json',
163 'reserved-member-u.json',
164 'reserved-member-underscore.json',
165 'reserved-type-kind.json',
166 'reserved-type-list.json',
167 'returns-alternate.json',
168 'returns-array-bad.json',
169 'returns-dict.json',
170 'returns-unknown.json',
171 'returns-whitelist.json',
172 'string-code-point-31.json',
173 'string-code-point-127.json',
174 'struct-base-clash-deep.json',
175 'struct-base-clash.json',
176 'struct-data-invalid.json',
177 'struct-member-if-invalid.json',
178 'struct-member-invalid-dict.json',
179 'struct-member-invalid.json',
180 'trailing-comma-list.json',
181 'trailing-comma-object.json',
182 'type-bypass-bad-gen.json',
183 'type-case.json',
184 'unclosed-list.json',
185 'unclosed-object.json',
186 'unclosed-string.json',
187 'union-base-empty.json',
188 'union-base-no-discriminator.json',
189 'union-branch-case.json',
190 'union-branch-if-invalid.json',
191 'union-branch-invalid-dict.json',
192 'union-clash-branches.json',
193 'union-empty.json',
194 'union-invalid-base.json',
195 'union-optional-branch.json',
196 'union-unknown.json',
197 'unknown-escape.json',
198 'unknown-expr-key.json',
199 ]
200
201 # Because people may want to use test-qapi.py from the command line, we
202 # are not using the "#! /usr/bin/env python3" trick here. See
203 # docs/devel/build-system.txt
204 test('QAPI schema regression tests', python, args: files('test-qapi.py', schemas),
205 env: test_env, suite: ['qapi-schema', 'qapi-frontend'])
206
207 diff = find_program('diff')
208
209 qapi_doc = custom_target('QAPI doc',
210 output: ['doc-good-qapi-commands.c', 'doc-good-qapi-commands.h',
211 'doc-good-qapi-emit-events.c', 'doc-good-qapi-emit-events.h',
212 'doc-good-qapi-events.c', 'doc-good-qapi-events.h',
213 'doc-good-qapi-init-commands.c', 'doc-good-qapi-init-commands.h',
214 'doc-good-qapi-introspect.c', 'doc-good-qapi-introspect.h',
215 'doc-good-qapi-types.c', 'doc-good-qapi-types.h',
216 'doc-good-qapi-visit.c', 'doc-good-qapi-visit.h' ],
217 input: files('doc-good.json'),
218 command: [ qapi_gen, '-o', meson.current_build_dir(),
219 '-p', 'doc-good-', '@INPUT0@' ],
220 depend_files: qapi_gen_depends)
221
222 if build_docs
223 # Test the document-comment document generation code by running a test schema
224 # file through Sphinx's plain-text builder and comparing the result against
225 # a golden reference. This is in theory susceptible to failures if Sphinx
226 # changes its output, but the text output has historically been very stable
227 # (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
228 # texinfo or HTML generation, both of which have had changes. We might
229 # need to add more sophisticated logic here in future for some sort of
230 # fuzzy comparison if future Sphinx versions produce different text,
231 # but for now the simple comparison suffices.
232 qapi_doc_out = custom_target('QAPI rST doc',
233 output: ['doc-good.txt'],
234 input: files('doc-good.json', 'doc-good.rst'),
235 build_by_default: true,
236 depend_files: sphinx_extn_depends,
237 # We use -E to suppress Sphinx's caching, because
238 # we want it to always really run the QAPI doc
239 # generation code. It also means we don't
240 # clutter up the build dir with the cache.
241 command: [SPHINX_ARGS,
242 '-b', 'text', '-E',
243 '-c', meson.source_root() / 'docs',
244 '-D', 'master_doc=doc-good',
245 meson.current_source_dir(),
246 meson.current_build_dir()])
247
248 # Fix possible inconsistency in line endings in generated output and
249 # in the golden reference (which could otherwise cause test failures
250 # on Windows hosts). Unfortunately diff --strip-trailing-cr
251 # is GNU-diff only. The odd-looking perl is because we must avoid
252 # using an explicit '\' character in the command arguments to
253 # a custom_target(), as Meson will unhelpfully replace it with a '/'
254 # (https://github.com/mesonbuild/meson/issues/1564)
255 qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
256 output: ['doc-good.txt.nocr'],
257 input: qapi_doc_out[0],
258 build_by_default: true,
259 command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
260 capture: true)
261
262 qapi_doc_ref_nocr = custom_target('QAPI rST doc reference newline-sanitized',
263 output: ['doc-good.ref.nocr'],
264 input: files('doc-good.txt'),
265 build_by_default: true,
266 command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
267 capture: true)
268
269 # "full_path()" needed here to work around
270 # https://github.com/mesonbuild/meson/issues/7585
271 test('QAPI rST doc', diff, args: ['-u', qapi_doc_ref_nocr[0].full_path(),
272 qapi_doc_out_nocr[0].full_path()],
273 depends: [qapi_doc_ref_nocr, qapi_doc_out_nocr],
274 suite: ['qapi-schema', 'qapi-doc'])
275 endif