From c7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 7 Mar 2020 00:34:05 +0530 Subject: coredata: Set default options as cmdline args that override each other The previous code was assuming that options do not depend on each other, and that you can set defaults using `dict.setdefault()`. This is not true for `buildtype` + `optimization`/`debug`, so we add defaults + overrides in the right order and use the options parsing code later to compute the values. Includes a test. Closes https://github.com/mesonbuild/meson/issues/6752 --- run_unittests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index baea70e..5b25b6c 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3825,6 +3825,24 @@ recommended as it is not supported on some platforms''') self.assertEqual(opts['debug'], True) self.assertEqual(opts['optimization'], '0') + # Command-line parsing of buildtype settings should be the same as + # setting with `meson configure`. + # + # Setting buildtype should set optimization/debug + self.new_builddir() + self.init(testdir, extra_args=['-Dbuildtype=debugoptimized']) + opts = self.get_opts_as_dict() + self.assertEqual(opts['debug'], True) + self.assertEqual(opts['optimization'], '2') + self.assertEqual(opts['buildtype'], 'debugoptimized') + # Setting optimization/debug should set buildtype + self.new_builddir() + self.init(testdir, extra_args=['-Doptimization=2', '-Ddebug=true']) + opts = self.get_opts_as_dict() + self.assertEqual(opts['debug'], True) + self.assertEqual(opts['optimization'], '2') + self.assertEqual(opts['buildtype'], 'debugoptimized') + @skipIfNoPkgconfig @unittest.skipIf(is_windows(), 'Help needed with fixing this test on windows') def test_native_dep_pkgconfig(self): -- cgit v1.1