Skip to content

Commit

Permalink
introspect: include choices for array options
Browse files Browse the repository at this point in the history
There was even a test covering this, but it did not fail due to a typo.
  • Loading branch information
bonzini authored and xclaesse committed Oct 14, 2021
1 parent 4f7c0d0 commit 5e96730
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mesonbuild/mintro.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def add_keys(options: 'cdata.KeyedOptionDictType', section: str) -> None:
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
Expand Down
7 changes: 5 additions & 2 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ def get_opt():
'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')
Expand All @@ -1621,6 +1622,7 @@ def get_opt():
'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')
Expand All @@ -1647,6 +1649,7 @@ def get_opt():
'section': 'user',
'type': 'array',
'value': [],
'choices': ['foo', 'bar', 'oink', 'boink'],
'machine': 'any',
}
tdir = os.path.join(self.unit_test_dir, '19 array option')
Expand Down Expand Up @@ -1703,7 +1706,7 @@ def test_options_with_choices_changing(self) -> None:
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'])

Expand All @@ -1721,7 +1724,7 @@ def test_options_with_choices_changing(self) -> None:
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'])

Expand Down

0 comments on commit 5e96730

Please sign in to comment.