diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-04-23 10:02:19 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-04-25 20:59:27 +0300 |
commit | b8f1b84733e1a217eb3f94146b668ded4dadef08 (patch) | |
tree | 70680588bea20adf0b1294dadc90373dd9cfc145 | |
parent | d4a5a8419fb85b8546f33c88dfe01f0f236a38e3 (diff) | |
download | meson-b8f1b84733e1a217eb3f94146b668ded4dadef08.zip meson-b8f1b84733e1a217eb3f94146b668ded4dadef08.tar.gz meson-b8f1b84733e1a217eb3f94146b668ded4dadef08.tar.bz2 |
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.
-rwxr-xr-x | run_unittests.py | 26 | ||||
-rw-r--r-- | test cases/unit/30 mixed command line args/meson.build | 1 | ||||
-rw-r--r-- | test cases/unit/30 mixed command line args/meson_options.txt | 10 |
3 files changed, 37 insertions, 0 deletions
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): ''' diff --git a/test cases/unit/30 mixed command line args/meson.build b/test cases/unit/30 mixed command line args/meson.build new file mode 100644 index 0000000..af5cdc7 --- /dev/null +++ b/test cases/unit/30 mixed command line args/meson.build @@ -0,0 +1 @@ +project('Mixed command line arguments') diff --git a/test cases/unit/30 mixed command line args/meson_options.txt b/test cases/unit/30 mixed command line args/meson_options.txt new file mode 100644 index 0000000..5a4bc22 --- /dev/null +++ b/test cases/unit/30 mixed command line args/meson_options.txt @@ -0,0 +1,10 @@ +option( + 'one', + type : 'string', +) +option( + 'two', + type : 'combo', + choices : ['foo', 'bar'], + value : 'foo', +) |