qapi: Enforce (or whitelist) case conventions on qapi members
commit893e1f2c5170d54316f1dcf3fefae679175622fc
authorEric Blake <eblake@redhat.com>
Wed, 2 Dec 2015 05:20:57 +0000 (1 22:20 -0700)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 17 Dec 2015 07:21:29 +0000 (17 08:21 +0100)
tree1c689f3a0462a4dc76b337c175ec305c5749dfbe
parent93bda4dd461358b4fc05dfd8e2d6419cdd574789
qapi: Enforce (or whitelist) case conventions on qapi members

We document that members of enums and objects should be
'lower-case', although we were not enforcing it.  We have to
whitelist a few pre-existing entities that violate the norms.
Add three new tests to expose the new error message, each of
which first uses the whitelisted name 'UuidInfo' to prove the
whitelist works, then triggers the failure (this is the same
pattern used in the existing returns-whitelist.json test).

Note that by adding this check, we have effectively forbidden
an entity with a case-insensitive clash of member names, for
any entity that is not on the whitelist (although there is
still the possibility to clash via '-' vs. '_').

Not done here: a future patch should also add naming convention
support and whitelist exceptions for command, event, and type
names.

The additions to QAPISchemaMember.check_clash() check whether
info['name'] is in the whitelist (the top-most entity name at
the point 'info' tracks), rather than self.owner (the type,
possibly implicit, that directly owns the member), because it
is easier to maintain the whitelist by the names actually in
the user's .json file, rather than worrying about the names
of implicit types.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1449033659-25497-14-git-send-email-eblake@redhat.com>
[Simplified a bit as per discussion with Eric]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
14 files changed:
scripts/qapi.py
tests/Makefile
tests/qapi-schema/args-member-case.err [new file with mode: 0644]
tests/qapi-schema/args-member-case.exit [new file with mode: 0644]
tests/qapi-schema/args-member-case.json [new file with mode: 0644]
tests/qapi-schema/args-member-case.out [new file with mode: 0644]
tests/qapi-schema/enum-member-case.err [new file with mode: 0644]
tests/qapi-schema/enum-member-case.exit [new file with mode: 0644]
tests/qapi-schema/enum-member-case.json [new file with mode: 0644]
tests/qapi-schema/enum-member-case.out [new file with mode: 0644]
tests/qapi-schema/union-branch-case.err [new file with mode: 0644]
tests/qapi-schema/union-branch-case.exit [new file with mode: 0644]
tests/qapi-schema/union-branch-case.json [new file with mode: 0644]
tests/qapi-schema/union-branch-case.out [new file with mode: 0644]