introspect: include choices for array options

There was even a test covering this, but it did not fail due to a typo.
pull/9401/head
Paolo Bonzini 3 years ago committed by Xavier Claessens
parent 4f7c0d0b62
commit 5e96730d7d
  1. 2
      mesonbuild/mintro.py
  2. 7
      unittests/allplatformstests.py

@ -287,6 +287,8 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
typestr = 'integer'
elif isinstance(opt, cdata.UserArrayOption):
typestr = 'array'
if opt.choices:
optdict['choices'] = opt.choices
else:
raise RuntimeError("Unknown option type")
optdict['type'] = typestr

@ -1595,6 +1595,7 @@ class AllPlatformTests(BasePlatformTests):
'section': 'user',
'type': 'array',
'value': ['foo', 'bar'],
'choices': ['foo', 'bar', 'oink', 'boink'],
'machine': 'any',
}
tdir = os.path.join(self.unit_test_dir, '19 array option')
@ -1621,6 +1622,7 @@ class AllPlatformTests(BasePlatformTests):
'section': 'user',
'type': 'array',
'value': ['foo', 'bar'],
'choices': ['foo', 'bar', 'oink', 'boink'],
'machine': 'any',
}
tdir = os.path.join(self.unit_test_dir, '19 array option')
@ -1647,6 +1649,7 @@ class AllPlatformTests(BasePlatformTests):
'section': 'user',
'type': 'array',
'value': [],
'choices': ['foo', 'bar', 'oink', 'boink'],
'machine': 'any',
}
tdir = os.path.join(self.unit_test_dir, '19 array option')
@ -1703,7 +1706,7 @@ class AllPlatformTests(BasePlatformTests):
if item['name'] == 'combo':
self.assertEqual(item['value'], 'b')
self.assertEqual(item['choices'], ['b', 'c', 'd'])
elif item['name'] == 'arr':
elif item['name'] == 'array':
self.assertEqual(item['value'], ['b'])
self.assertEqual(item['choices'], ['b', 'c', 'd'])
@ -1721,7 +1724,7 @@ class AllPlatformTests(BasePlatformTests):
if item['name'] == 'combo':
self.assertEqual(item['value'], 'c')
self.assertEqual(item['choices'], ['b', 'c', 'd'])
elif item['name'] == 'arr':
elif item['name'] == 'array':
self.assertEqual(item['value'], ['b', 'c'])
self.assertEqual(item['choices'], ['b', 'c', 'd'])

Loading…
Cancel
Save