diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-09-29 10:07:29 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-11-29 14:14:41 -0800 |
commit | c9351ce30c03d107279090da7825096951a705d3 (patch) | |
tree | a9bf94236755986b2f69d2ef297e339c3c898561 /run_unittests.py | |
parent | 7c779a76df9b8a4dd466b120f817b50f857081fa (diff) | |
download | meson-c9351ce30c03d107279090da7825096951a705d3.zip meson-c9351ce30c03d107279090da7825096951a705d3.tar.gz meson-c9351ce30c03d107279090da7825096951a705d3.tar.bz2 |
Add new array type option
This exposes the already existing UserStringArrayOption class through
the meson_options.txt. The intention is to provide a way for projects to
take list/array type arguments and validate that all of the elements in
that array are valid without using complex looping constructrs.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index 91a71ce..42f4e19 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1562,6 +1562,53 @@ int main(int argc, char **argv) { cargs = ['-I' + incdir.as_posix()] self.assertEqual(foo_dep.get_compile_args(), cargs) + def test_array_option_change(self): + def get_opt(): + opts = self.introspect('--buildoptions') + for x in opts: + if x.get('name') == 'list': + return x + raise Exception(opts) + + expected = { + 'name': 'list', + 'description': 'list', + 'type': 'stringarray', + 'value': ['foo', 'bar'], + } + tdir = os.path.join(self.unit_test_dir, '18 array option') + self.init(tdir) + original = get_opt() + self.assertDictEqual(original, expected) + + expected['value'] = ['oink', 'boink'] + self.setconf('-Dlist=oink,boink') + changed = get_opt() + self.assertEqual(changed, expected) + + def test_array_option_bad_change(self): + def get_opt(): + opts = self.introspect('--buildoptions') + for x in opts: + if x.get('name') == 'list': + return x + raise Exception(opts) + + expected = { + 'name': 'list', + 'description': 'list', + 'type': 'stringarray', + 'value': ['foo', 'bar'], + } + tdir = os.path.join(self.unit_test_dir, '18 array option') + self.init(tdir) + original = get_opt() + self.assertDictEqual(original, expected) + with self.assertRaises(subprocess.CalledProcessError): + self.setconf('-Dlist=bad') + changed = get_opt() + self.assertDictEqual(changed, expected) + class FailureTests(BasePlatformTests): ''' |