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