From b8f1b84733e1a217eb3f94146b668ded4dadef08 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 23 Apr 2018 10:02:19 -0700 Subject: Tests: Add some tests for mixing -Dfoo and --foo These are at least some of the tests that really deserved to be written for 78e37c495326325ae003683411971779291f8324, but I was lazy. --- run_unittests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index 3f80f74..be48f11 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2020,6 +2020,32 @@ recommended as it can lead to undefined behaviour on some platforms''') self.builddir = exebuilddir self.assertRebuiltTarget('app') + def test_conflicting_d_dash_option(self): + testdir = os.path.join(self.unit_test_dir, '30 mixed command line args') + with self.assertRaises(subprocess.CalledProcessError) as e: + self.init(testdir, extra_args=['-Dbindir=foo', '--bindir=bar']) + # Just to ensure that we caught the correct error + self.assertIn('passed as both', e.stderr) + + def _test_same_option_twice(self, arg, args): + testdir = os.path.join(self.unit_test_dir, '30 mixed command line args') + self.init(testdir, extra_args=args) + opts = self.introspect('--buildoptions') + for item in opts: + if item['name'] == arg: + self.assertEqual(item['value'], 'bar') + return + raise Exception('Missing {} value?'.format(arg)) + + def test_same_dash_option_twice(self): + self._test_same_option_twice('bindir', ['--bindir=foo', '--bindir=bar']) + + def test_same_d_option_twice(self): + self._test_same_option_twice('bindir', ['-Dbindir=foo', '-Dbindir=bar']) + + def test_same_project_d_option_twice(self): + self._test_same_option_twice('one', ['-Done=foo', '-Done=bar']) + class FailureTests(BasePlatformTests): ''' -- cgit v1.1