qapi/parser: Fix token membership tests when token can be None
authorJohn Snow <jsnow@redhat.com>
Wed, 19 May 2021 18:39:46 +0000 (14:39 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 20 May 2021 09:28:28 +0000 (11:28 +0200)
commitc256263f3df0eaf9011405cdaee354380beb6dc5
treefa0a2f0ee34cac84f609bffe27ea26dc390f3e52
parente0e8a0ac2e60fdebd7ff0f831250c849f22af35d
qapi/parser: Fix token membership tests when token can be None

When the token can be None (EOF), we can't use 'x in "abc"' style
membership tests to group types of tokens together, because 'None in
"abc"' is a TypeError.

Easy enough to fix. (Use a tuple: It's neither a static typing error nor
a runtime error to check for None in Tuple[str, ...])

Add tests to prevent a regression. (Note: they cannot be added prior to
this fix, as the unhandled stack trace will not match test output in the
CI system.)

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210519183951.3946870-11-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/parser.py
tests/qapi-schema/meson.build
tests/qapi-schema/missing-array-rsqb.err [new file with mode: 0644]
tests/qapi-schema/missing-array-rsqb.json [new file with mode: 0644]
tests/qapi-schema/missing-array-rsqb.out [new file with mode: 0644]
tests/qapi-schema/missing-object-member-element.err [new file with mode: 0644]
tests/qapi-schema/missing-object-member-element.json [new file with mode: 0644]
tests/qapi-schema/missing-object-member-element.out [new file with mode: 0644]