Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/qapi-schema: Demonstrate misleading optional tag error
Test flat-union-optional-discriminator declares its union tag as '*switch': 'Enum', and points to it with 'discriminator': '*switch'. This gets rejected as "discriminator of flat union 'MyUnion' uses invalid name '*switch'". Correct; member 'discriminator' doesn't accept a '*' prefix. However, this merely tests name validity checking, which we already cover elsewhere. More interesting is testing the valid name 'switch'. This reports "discriminator 'switch' is not a member of base struct 'Base'", which is misleading. Copy the existing 'discriminator': '*switch' test to flat-union-discriminator-bad-name, and rewrite its comment. Change flat-union-optional-discriminator to test 'discriminator': 'switch', and mark it FIXME. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190914153506.2151-4-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
- Loading branch information
Markus Armbruster
committed
Sep 24, 2019
1 parent
352ada9
commit cd346bd
Showing
7 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/qapi-schema/flat-union-discriminator-bad-name.json:7: Discriminator of flat union 'MyUnion' does not allow optional name '*switch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# discriminator '*switch' isn't a member of base, 'switch' is | ||
# reports "does not allow optional name", which is good enough | ||
{ 'enum': 'Enum', 'data': [ 'one', 'two' ] } | ||
{ 'struct': 'Base', | ||
'data': { '*switch': 'Enum' } } | ||
{ 'struct': 'Branch', 'data': { 'name': 'str' } } | ||
{ 'union': 'MyUnion', | ||
'base': 'Base', | ||
'discriminator': '*switch', | ||
'data': { 'one': 'Branch', | ||
'two': 'Branch' } } |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
tests/qapi-schema/flat-union-optional-discriminator.json:6: Discriminator of flat union 'MyUnion' does not allow optional name '*switch' | ||
tests/qapi-schema/flat-union-optional-discriminator.json:7: Discriminator 'switch' is not a member of base struct 'Base' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# we require the discriminator to be non-optional | ||
# FIXME reports "discriminator 'switch' is not a member of base struct 'Base'" | ||
{ 'enum': 'Enum', 'data': [ 'one', 'two' ] } | ||
{ 'struct': 'Base', | ||
'data': { '*switch': 'Enum' } } | ||
{ 'struct': 'Branch', 'data': { 'name': 'str' } } | ||
{ 'union': 'MyUnion', | ||
'base': 'Base', | ||
'discriminator': '*switch', | ||
'discriminator': 'switch', | ||
'data': { 'one': 'Branch', | ||
'two': 'Branch' } } |