qemu-e2k/tests/qapi-schema/meson.build
Peter Maydell a69a6d4b4d scripts/qapi/parser.py: improve doc comment indent handling
Make the handling of indentation in doc comments more sophisticated,
so that when we see a section like:

Notes: some text
       some more text
          indented line 3

we save it for the doc-comment processing code as:

some text
some more text
   indented line 3

and when we see a section with the heading on its own line:

Notes:

some text
some more text
   indented text

we also accept that and save it in the same form.

If we detect that the comment document text is not indented as much
as we expect it to be, we throw a parse error.  (We don't complain
about over-indented sections, because for rST this can be legitimate
markup.)

The golden reference for the doc comment text is updated to remove
the two 'wrong' indents; these now form a test case that we correctly
stripped leading whitespace from an indented multi-line argument
definition.

We update the documentation in docs/devel/qapi-code-gen.txt to
describe the new indentation rules.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20200925162316.21205-6-peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Whitespace between sentences tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2020-09-29 17:55:39 +02:00

227 lines
7.1 KiB
Meson

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',
'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-name-clash.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',
'doc-bad-indent.json',
'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.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',
'missing-colon.json',
'missing-comma-list.json',
'missing-comma-object.json',
'missing-type.json',
'nested-struct-data.json',
'nested-struct-data-invalid-dict.json',
'non-objects.json',
'oob-test.json',
'allow-preconfig-test.json',
'pragma-doc-required-crap.json',
'pragma-extra-junk.json',
'pragma-name-case-whitelist-crap.json',
'pragma-non-dict.json',
'pragma-unknown.json',
'pragma-returns-whitelist-crap.json',
'qapi-schema-test.json',
'quoted-structural-chars.json',
'redefined-builtin.json',
'redefined-command.json',
'redefined-event.json',
'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',
'returns-dict.json',
'returns-unknown.json',
'returns-whitelist.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',
'trailing-comma-list.json',
'trailing-comma-object.json',
'type-bypass-bad-gen.json',
'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',
'union-optional-branch.json',
'union-unknown.json',
'unknown-escape.json',
'unknown-expr-key.json',
]
# 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
test('QAPI schema regression tests', python, args: files('test-qapi.py', schemas),
env: test_env, suite: ['qapi-schema', 'qapi-frontend'])
diff = find_program('diff')
qapi_doc = custom_target('QAPI doc',
output: ['doc-good-qapi-doc.texi',
'doc-good-qapi-commands.c', 'doc-good-qapi-commands.h',
'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)
# "full_path()" needed here to work around
# https://github.com/mesonbuild/meson/issues/7585
test('QAPI doc', diff, args: ['-b', '-u', files('doc-good.texi'), qapi_doc[0].full_path()],
depends: qapi_doc,
suite: ['qapi-schema', 'qapi-doc'])