John Snow <jsnow@redhat.com> writes:
On 3/23/21 5:40 AM, Markus Armbruster wrote:
Member name 'u' and names starting with 'has-' or 'has_' are reserved
for the generator. check_type() enforces this, covered by tests
reserved-member-u and reserved-member-has.
These tests neglect to cover optional members, where the name starts
with '*'. Tweak reserved-member-u to fix that.
This demonstrates the reserved member name check is broken for
optional members. The next commit will fix it.
The test without an optional member goes away. Do we lose coverage?
(Do we care?)
Up to a point :) We do try to cover all failure modes, just not in all
contexts.
The test is about this error:
if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'):
raise QAPISemError(info, "%s uses reserved name" % key_source)
Full matrix: (is "u", starts with "has_") x (optional, not optional).
Instead of covering all four cases, we cover two: non-optional "u"
(reserved-member-u) and non-optional "has-" (reserved-member-has).
The patch flips the former to optional. The latter still covers
non-optional.
Good enough, I think.