From f3a8f9c34d95d862fb4d12869a7b31cea592561f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 5 Jun 2018 08:33:36 -0700 Subject: Options: treat array option -Dopt= and -Dopt=[] as equivalent Currently the former will be parsed as [''], while the latter is parsed as [] in python. This makes for some obnoxious special handling depending on what the user passes. This is even more obnoxious since for string type arguments this doesn't require special handling. --- run_unittests.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 4cfb743..0abe419 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1786,6 +1786,26 @@ int main(int argc, char **argv) { changed = get_opt() self.assertDictEqual(changed, expected) + def test_array_option_empty_equivalents(self): + """Array options treat -Dopt=[] and -Dopt= as equivalent.""" + 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': 'array', + 'value': [], + } + tdir = os.path.join(self.unit_test_dir, '18 array option') + self.init(tdir, extra_args='-Dlist=') + original = get_opt() + self.assertDictEqual(original, expected) + def opt_has(self, name, value): res = self.introspect('--buildoptions') found = False -- cgit v1.1