2020-01-28 20:05:14 +03:00
|
|
|
test_env = environment()
|
|
|
|
test_env.set('PYTHONPATH', meson.source_root() / 'scripts')
|
|
|
|
test_env.set('PYTHONIOENCODING', 'utf-8')
|
|
|
|
|
|
|
|
schemas = [
|
|
|
|
'alternate-any.json',
|
|
|
|
'alternate-array.json',
|
|
|
|
'alternate-base.json',
|
|
|
|
'alternate-branch-if-invalid.json',
|
|
|
|
'alternate-clash.json',
|
|
|
|
'alternate-conflict-dict.json',
|
|
|
|
'alternate-conflict-enum-bool.json',
|
|
|
|
'alternate-conflict-enum-int.json',
|
|
|
|
'alternate-conflict-string.json',
|
|
|
|
'alternate-conflict-bool-string.json',
|
|
|
|
'alternate-conflict-num-string.json',
|
2021-04-21 21:20:22 +03:00
|
|
|
'alternate-data-invalid.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'alternate-empty.json',
|
|
|
|
'alternate-invalid-dict.json',
|
|
|
|
'alternate-nested.json',
|
|
|
|
'alternate-unknown.json',
|
|
|
|
'args-alternate.json',
|
|
|
|
'args-any.json',
|
|
|
|
'args-array-empty.json',
|
|
|
|
'args-array-unknown.json',
|
|
|
|
'args-bad-boxed.json',
|
|
|
|
'args-boxed-anon.json',
|
|
|
|
'args-boxed-string.json',
|
|
|
|
'args-int.json',
|
|
|
|
'args-invalid.json',
|
|
|
|
'args-member-array-bad.json',
|
|
|
|
'args-member-case.json',
|
|
|
|
'args-member-unknown.json',
|
|
|
|
'args-union.json',
|
|
|
|
'args-unknown.json',
|
|
|
|
'bad-base.json',
|
|
|
|
'bad-data.json',
|
|
|
|
'bad-ident.json',
|
|
|
|
'bad-if.json',
|
|
|
|
'bad-if-empty.json',
|
|
|
|
'bad-if-empty-list.json',
|
|
|
|
'bad-if-list.json',
|
|
|
|
'bad-type-bool.json',
|
|
|
|
'bad-type-dict.json',
|
|
|
|
'bad-type-int.json',
|
|
|
|
'base-cycle-direct.json',
|
|
|
|
'base-cycle-indirect.json',
|
|
|
|
'command-int.json',
|
|
|
|
'comments.json',
|
|
|
|
'doc-bad-alternate-member.json',
|
|
|
|
'doc-bad-boxed-command-arg.json',
|
|
|
|
'doc-bad-command-arg.json',
|
|
|
|
'doc-bad-enum-member.json',
|
|
|
|
'doc-bad-event-arg.json',
|
|
|
|
'doc-bad-feature.json',
|
2020-09-25 19:23:00 +03:00
|
|
|
'doc-bad-indent.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'doc-bad-section.json',
|
|
|
|
'doc-bad-symbol.json',
|
|
|
|
'doc-bad-union-member.json',
|
|
|
|
'doc-before-include.json',
|
|
|
|
'doc-before-pragma.json',
|
|
|
|
'doc-duplicated-arg.json',
|
|
|
|
'doc-duplicated-return.json',
|
|
|
|
'doc-duplicated-since.json',
|
|
|
|
'doc-empty-arg.json',
|
|
|
|
'doc-empty-section.json',
|
|
|
|
'doc-empty-symbol.json',
|
|
|
|
'doc-good.json',
|
|
|
|
'doc-interleaved-section.json',
|
|
|
|
'doc-invalid-end.json',
|
|
|
|
'doc-invalid-end2.json',
|
|
|
|
'doc-invalid-return.json',
|
|
|
|
'doc-invalid-section.json',
|
|
|
|
'doc-invalid-start.json',
|
|
|
|
'doc-missing-colon.json',
|
|
|
|
'doc-missing-expr.json',
|
|
|
|
'doc-missing-space.json',
|
|
|
|
'doc-missing.json',
|
|
|
|
'doc-no-symbol.json',
|
|
|
|
'doc-undoc-feature.json',
|
|
|
|
'double-type.json',
|
|
|
|
'duplicate-key.json',
|
|
|
|
'empty.json',
|
|
|
|
'enum-bad-member.json',
|
|
|
|
'enum-bad-name.json',
|
|
|
|
'enum-bad-prefix.json',
|
|
|
|
'enum-clash-member.json',
|
|
|
|
'enum-dict-member-unknown.json',
|
|
|
|
'enum-if-invalid.json',
|
|
|
|
'enum-int-member.json',
|
|
|
|
'enum-member-case.json',
|
|
|
|
'enum-missing-data.json',
|
|
|
|
'enum-wrong-data.json',
|
|
|
|
'event-boxed-empty.json',
|
|
|
|
'event-case.json',
|
|
|
|
'event-member-invalid-dict.json',
|
|
|
|
'event-nest-struct.json',
|
|
|
|
'features-bad-type.json',
|
|
|
|
'features-deprecated-type.json',
|
|
|
|
'features-duplicate-name.json',
|
|
|
|
'features-if-invalid.json',
|
|
|
|
'features-missing-name.json',
|
|
|
|
'features-name-bad-type.json',
|
|
|
|
'features-no-list.json',
|
|
|
|
'features-unknown-key.json',
|
|
|
|
'flat-union-array-branch.json',
|
|
|
|
'flat-union-bad-base.json',
|
|
|
|
'flat-union-bad-discriminator.json',
|
|
|
|
'flat-union-base-any.json',
|
|
|
|
'flat-union-base-union.json',
|
|
|
|
'flat-union-clash-member.json',
|
|
|
|
'flat-union-discriminator-bad-name.json',
|
|
|
|
'flat-union-empty.json',
|
|
|
|
'flat-union-inline-invalid-dict.json',
|
|
|
|
'flat-union-int-branch.json',
|
|
|
|
'flat-union-invalid-branch-key.json',
|
|
|
|
'flat-union-invalid-discriminator.json',
|
|
|
|
'flat-union-invalid-if-discriminator.json',
|
|
|
|
'flat-union-no-base.json',
|
|
|
|
'flat-union-optional-discriminator.json',
|
|
|
|
'flat-union-string-discriminator.json',
|
|
|
|
'funny-char.json',
|
|
|
|
'funny-word.json',
|
|
|
|
'ident-with-escape.json',
|
|
|
|
'include-before-err.json',
|
|
|
|
'include-cycle.json',
|
|
|
|
'include-extra-junk.json',
|
|
|
|
'include-nested-err.json',
|
|
|
|
'include-no-file.json',
|
|
|
|
'include-non-file.json',
|
|
|
|
'include-repetition.json',
|
|
|
|
'include-self-cycle.json',
|
|
|
|
'include-simple.json',
|
|
|
|
'indented-expr.json',
|
|
|
|
'leading-comma-list.json',
|
|
|
|
'leading-comma-object.json',
|
2021-05-19 21:39:46 +03:00
|
|
|
'missing-array-rsqb.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'missing-colon.json',
|
|
|
|
'missing-comma-list.json',
|
|
|
|
'missing-comma-object.json',
|
2021-05-19 21:39:46 +03:00
|
|
|
'missing-object-member-element.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'missing-type.json',
|
|
|
|
'nested-struct-data.json',
|
|
|
|
'nested-struct-data-invalid-dict.json',
|
|
|
|
'non-objects.json',
|
2020-10-05 18:58:49 +03:00
|
|
|
'oob-coroutine.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'oob-test.json',
|
|
|
|
'allow-preconfig-test.json',
|
|
|
|
'pragma-extra-junk.json',
|
|
|
|
'pragma-non-dict.json',
|
|
|
|
'pragma-unknown.json',
|
2021-03-23 12:40:14 +03:00
|
|
|
'pragma-value-not-bool.json',
|
|
|
|
'pragma-value-not-list-of-str.json',
|
|
|
|
'pragma-value-not-list.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'qapi-schema-test.json',
|
|
|
|
'quoted-structural-chars.json',
|
|
|
|
'redefined-command.json',
|
|
|
|
'redefined-event.json',
|
2021-03-23 12:40:12 +03:00
|
|
|
'redefined-predefined.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'redefined-type.json',
|
|
|
|
'reserved-command-q.json',
|
|
|
|
'reserved-enum-q.json',
|
|
|
|
'reserved-member-has.json',
|
|
|
|
'reserved-member-q.json',
|
|
|
|
'reserved-member-u.json',
|
|
|
|
'reserved-member-underscore.json',
|
|
|
|
'reserved-type-kind.json',
|
|
|
|
'reserved-type-list.json',
|
|
|
|
'returns-alternate.json',
|
|
|
|
'returns-array-bad.json',
|
2021-03-23 12:40:15 +03:00
|
|
|
'returns-bad-type.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'returns-dict.json',
|
|
|
|
'returns-unknown.json',
|
|
|
|
'string-code-point-31.json',
|
|
|
|
'string-code-point-127.json',
|
|
|
|
'struct-base-clash-deep.json',
|
|
|
|
'struct-base-clash.json',
|
|
|
|
'struct-data-invalid.json',
|
|
|
|
'struct-member-if-invalid.json',
|
|
|
|
'struct-member-invalid-dict.json',
|
|
|
|
'struct-member-invalid.json',
|
2021-03-23 12:40:22 +03:00
|
|
|
'struct-member-name-clash.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'trailing-comma-list.json',
|
|
|
|
'trailing-comma-object.json',
|
|
|
|
'type-bypass-bad-gen.json',
|
2021-03-23 12:40:11 +03:00
|
|
|
'type-case.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'unclosed-list.json',
|
|
|
|
'unclosed-object.json',
|
|
|
|
'unclosed-string.json',
|
|
|
|
'union-base-empty.json',
|
|
|
|
'union-base-no-discriminator.json',
|
|
|
|
'union-branch-case.json',
|
|
|
|
'union-branch-if-invalid.json',
|
|
|
|
'union-branch-invalid-dict.json',
|
|
|
|
'union-clash-branches.json',
|
|
|
|
'union-empty.json',
|
|
|
|
'union-invalid-base.json',
|
2021-04-21 21:20:22 +03:00
|
|
|
'union-invalid-data.json',
|
2020-01-28 20:05:14 +03:00
|
|
|
'union-optional-branch.json',
|
|
|
|
'union-unknown.json',
|
|
|
|
'unknown-escape.json',
|
|
|
|
'unknown-expr-key.json',
|
|
|
|
]
|
2021-05-19 21:39:38 +03:00
|
|
|
schemas = files(schemas)
|
|
|
|
|
|
|
|
# Intentionally missing schema file test -- not passed through files():
|
|
|
|
schemas += [meson.current_source_dir() / 'missing-schema.json']
|
2020-01-28 20:05:14 +03:00
|
|
|
|
|
|
|
# Because people may want to use test-qapi.py from the command line, we
|
|
|
|
# are not using the "#! /usr/bin/env python3" trick here. See
|
|
|
|
# docs/devel/build-system.txt
|
2021-05-19 21:39:38 +03:00
|
|
|
test('QAPI schema regression tests', python,
|
|
|
|
args: files('test-qapi.py') + schemas,
|
2020-01-28 20:05:14 +03:00
|
|
|
env: test_env, suite: ['qapi-schema', 'qapi-frontend'])
|
|
|
|
|
|
|
|
diff = find_program('diff')
|
|
|
|
|
|
|
|
qapi_doc = custom_target('QAPI doc',
|
2020-09-25 19:23:11 +03:00
|
|
|
output: ['doc-good-qapi-commands.c', 'doc-good-qapi-commands.h',
|
2020-01-28 20:05:14 +03:00
|
|
|
'doc-good-qapi-emit-events.c', 'doc-good-qapi-emit-events.h',
|
|
|
|
'doc-good-qapi-events.c', 'doc-good-qapi-events.h',
|
|
|
|
'doc-good-qapi-init-commands.c', 'doc-good-qapi-init-commands.h',
|
|
|
|
'doc-good-qapi-introspect.c', 'doc-good-qapi-introspect.h',
|
|
|
|
'doc-good-qapi-types.c', 'doc-good-qapi-types.h',
|
|
|
|
'doc-good-qapi-visit.c', 'doc-good-qapi-visit.h' ],
|
|
|
|
input: files('doc-good.json'),
|
|
|
|
command: [ qapi_gen, '-o', meson.current_build_dir(),
|
|
|
|
'-p', 'doc-good-', '@INPUT0@' ],
|
|
|
|
depend_files: qapi_gen_depends)
|
|
|
|
|
2020-10-16 11:05:26 +03:00
|
|
|
if build_docs
|
|
|
|
# Test the document-comment document generation code by running a test schema
|
|
|
|
# file through Sphinx's plain-text builder and comparing the result against
|
|
|
|
# a golden reference. This is in theory susceptible to failures if Sphinx
|
|
|
|
# changes its output, but the text output has historically been very stable
|
|
|
|
# (no changes between Sphinx 1.6 and 3.0), so it is a better bet than
|
|
|
|
# texinfo or HTML generation, both of which have had changes. We might
|
|
|
|
# need to add more sophisticated logic here in future for some sort of
|
|
|
|
# fuzzy comparison if future Sphinx versions produce different text,
|
|
|
|
# but for now the simple comparison suffices.
|
|
|
|
qapi_doc_out = custom_target('QAPI rST doc',
|
|
|
|
output: ['doc-good.txt'],
|
|
|
|
input: files('doc-good.json', 'doc-good.rst'),
|
|
|
|
build_by_default: true,
|
|
|
|
depend_files: sphinx_extn_depends,
|
|
|
|
# We use -E to suppress Sphinx's caching, because
|
|
|
|
# we want it to always really run the QAPI doc
|
|
|
|
# generation code. It also means we don't
|
|
|
|
# clutter up the build dir with the cache.
|
|
|
|
command: [SPHINX_ARGS,
|
|
|
|
'-b', 'text', '-E',
|
|
|
|
'-c', meson.source_root() / 'docs',
|
|
|
|
'-D', 'master_doc=doc-good',
|
|
|
|
meson.current_source_dir(),
|
|
|
|
meson.current_build_dir()])
|
2020-09-25 19:23:10 +03:00
|
|
|
|
2020-10-16 11:05:26 +03:00
|
|
|
# Fix possible inconsistency in line endings in generated output and
|
|
|
|
# in the golden reference (which could otherwise cause test failures
|
|
|
|
# on Windows hosts). Unfortunately diff --strip-trailing-cr
|
|
|
|
# is GNU-diff only. The odd-looking perl is because we must avoid
|
|
|
|
# using an explicit '\' character in the command arguments to
|
|
|
|
# a custom_target(), as Meson will unhelpfully replace it with a '/'
|
|
|
|
# (https://github.com/mesonbuild/meson/issues/1564)
|
|
|
|
qapi_doc_out_nocr = custom_target('QAPI rST doc newline-sanitized',
|
|
|
|
output: ['doc-good.txt.nocr'],
|
|
|
|
input: qapi_doc_out[0],
|
|
|
|
build_by_default: true,
|
|
|
|
command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
|
|
|
|
capture: true)
|
2020-09-25 19:23:10 +03:00
|
|
|
|
2020-10-16 11:05:26 +03:00
|
|
|
qapi_doc_ref_nocr = custom_target('QAPI rST doc reference newline-sanitized',
|
|
|
|
output: ['doc-good.ref.nocr'],
|
|
|
|
input: files('doc-good.txt'),
|
|
|
|
build_by_default: true,
|
|
|
|
command: ['perl', '-pe', '$x = chr 13; s/$x$//', '@INPUT@'],
|
|
|
|
capture: true)
|
2020-09-25 19:23:10 +03:00
|
|
|
|
|
|
|
# "full_path()" needed here to work around
|
|
|
|
# https://github.com/mesonbuild/meson/issues/7585
|
|
|
|
test('QAPI rST doc', diff, args: ['-u', qapi_doc_ref_nocr[0].full_path(),
|
|
|
|
qapi_doc_out_nocr[0].full_path()],
|
|
|
|
depends: [qapi_doc_ref_nocr, qapi_doc_out_nocr],
|
|
|
|
suite: ['qapi-schema', 'qapi-doc'])
|
|
|
|
endif
|