tests: print enum type members more like object type members

Commit 93bda4dd46 changed the internal representation of enum type
members from str to QAPISchemaMember, but we still print only a
string.  Has been good enough, as the name is the member's only
attribute of interest, but that's about to change.  To prepare, print
them more like object type members.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20181213123724.4866-4-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-12-13 16:37:05 +04:00 committed by Markus Armbruster
parent 1962bd39d5
commit 1e381b6559
12 changed files with 149 additions and 27 deletions

View File

@ -1,5 +1,15 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module comments.json
enum Status ['good', 'bad', 'ugly']
enum Status
member good
member bad
member ugly

View File

@ -1,8 +1,17 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module doc-bad-section.json
enum Enum ['one', 'two']
enum Enum
member one
member two
doc symbol=Enum
body=
== Produces *invalid* texinfo

View File

@ -1,8 +1,17 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module doc-good.json
enum Enum ['one', 'two']
enum Enum
member one
member two
if ['defined(IFCOND)']
object Base
member base1: Enum optional=False
@ -18,7 +27,9 @@ object q_obj_Variant1-wrapper
member data: Variant1 optional=False
object q_obj_Variant2-wrapper
member data: Variant2 optional=False
enum SugaredUnionKind ['one', 'two']
enum SugaredUnionKind
member one
member two
object SugaredUnion
member type: SugaredUnionKind optional=False
tag type

View File

@ -1,3 +1,10 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool

View File

@ -1,6 +1,13 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module event-case.json
event oops None
boxed=False

View File

@ -1,6 +1,13 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module ident-with-escape.json
object q_obj_fooA-arg
member bar1: str optional=False

View File

@ -1,9 +1,19 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module include-relpath.json
include include/relpath.json
module include/relpath.json
include include-relpath-sub.json
module include-relpath-sub.json
enum Status ['good', 'bad', 'ugly']
enum Status
member good
member bad
member ugly

View File

@ -1,10 +1,20 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module include-repetition.json
include comments.json
module comments.json
enum Status ['good', 'bad', 'ugly']
enum Status
member good
member bad
member ugly
module include-repetition.json
include include-repetition-sub.json
module include-repetition-sub.json

View File

@ -1,7 +1,17 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module include-simple.json
include include-simple-sub.json
module include-simple-sub.json
enum Status ['good', 'bad', 'ugly']
enum Status
member good
member bad
member ugly

View File

@ -1,6 +1,13 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module indented-expr.json
command eins None -> None
gen=True success_response=True boxed=False oob=False preconfig=False

View File

@ -1,6 +1,13 @@
object q_empty
enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
enum QType
prefix QTYPE
member none
member qnull
member qnum
member qstring
member qdict
member qlist
member qbool
module qapi-schema-test.json
object TestStruct
member integer: int optional=False
@ -11,19 +18,25 @@ object NestedEnumsOne
member enum2: EnumOne optional=True
member enum3: EnumOne optional=False
member enum4: EnumOne optional=True
enum MyEnum []
enum MyEnum
object Empty1
object Empty2
base Empty1
command user_def_cmd0 Empty2 -> Empty2
gen=True success_response=True boxed=False oob=False preconfig=False
enum QEnumTwo ['value1', 'value2']
enum QEnumTwo
prefix QENUM_TWO
member value1
member value2
object UserDefOne
base UserDefZero
member string: str optional=False
member enum1: EnumOne optional=True
enum EnumOne ['value1', 'value2', 'value3', 'value4']
enum EnumOne
member value1
member value2
member value3
member value4
object UserDefZero
member integer: int optional=False
object UserDefTwoDictDict
@ -127,7 +140,21 @@ object q_obj_sizeList-wrapper
member data: sizeList optional=False
object q_obj_anyList-wrapper
member data: anyList optional=False
enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any']
enum UserDefNativeListUnionKind
member integer
member s8
member s16
member s32
member s64
member u8
member u16
member u32
member u64
member number
member boolean
member string
member sizes
member any
object UserDefNativeListUnion
member type: UserDefNativeListUnionKind optional=False
tag type
@ -204,7 +231,8 @@ event EVENT_E UserDefZero
boxed=True
event EVENT_F UserDefAlternate
boxed=True
enum __org.qemu_x-Enum ['__org.qemu_x-value']
enum __org.qemu_x-Enum
member __org.qemu_x-value
object __org.qemu_x-Base
member __org.qemu_x-member1: __org.qemu_x-Enum optional=False
object __org.qemu_x-Struct
@ -213,7 +241,8 @@ object __org.qemu_x-Struct
member wchar-t: int optional=True
object q_obj_str-wrapper
member data: str optional=False
enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch']
enum __org.qemu_x-Union1Kind
member __org.qemu_x-branch
object __org.qemu_x-Union1
member type: __org.qemu_x-Union1Kind optional=False
tag type
@ -240,11 +269,14 @@ command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_x-Unio
object TestIfStruct
member foo: int optional=False
if ['defined(TEST_IF_STRUCT)']
enum TestIfEnum ['foo', 'bar']
enum TestIfEnum
member foo
member bar
if ['defined(TEST_IF_ENUM)']
object q_obj_TestStruct-wrapper
member data: TestStruct optional=False
enum TestIfUnionKind ['foo']
enum TestIfUnionKind
member foo
if ['defined(TEST_IF_UNION) && defined(TEST_IF_STRUCT)']
object TestIfUnion
member type: TestIfUnionKind optional=False

View File

@ -24,9 +24,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
print('include %s' % name)
def visit_enum_type(self, name, info, ifcond, members, prefix):
print('enum %s %s' % (name, [m.name for m in members]))
print('enum %s' % name)
if prefix:
print(' prefix %s' % prefix)
for m in members:
print(' member %s' % m.name)
self._print_if(ifcond)
def visit_object_type(self, name, info, ifcond, base, members, variants):