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