aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-10-13 09:56:59 +0200
committerXavier Claessens <xclaesse@gmail.com>2021-10-14 09:04:25 -0400
commit5e96730d7d9f1f6bebf66d04381bc5ec0f80a1cc (patch)
tree5be9524d64643808d012d3da2cc7896914403c48
parent4f7c0d0b62e0599f68b37b39d6d346cfb02295f0 (diff)
downloadmeson-5e96730d7d9f1f6bebf66d04381bc5ec0f80a1cc.zip
meson-5e96730d7d9f1f6bebf66d04381bc5ec0f80a1cc.tar.gz
meson-5e96730d7d9f1f6bebf66d04381bc5ec0f80a1cc.tar.bz2
introspect: include choices for array options
There was even a test covering this, but it did not fail due to a typo.
-rw-r--r--mesonbuild/mintro.py2
-rw-r--r--unittests/allplatformstests.py7
2 files changed, 7 insertions, 2 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 8408720..130cf93 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.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
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 7af5956..da461e4 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -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'])