From 3cf4f657e24fcebbdbba994fae5a277bf304ce14 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 16 Mar 2021 08:58:04 +0100 Subject: [PATCH] msetup: do not print bogus "Option ... is:" messages get_non_matching_default_options is checking a string from project_default_options against a validated value from coredata.options. Passing the string to validate_value ensures that the comparison is sound; otherwise, "false" might be compared against False and a bogus difference is printed. --- mesonbuild/interpreter.py | 7 ++++++- run_unittests.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 60fc06392..25ff7a4bd 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2478,7 +2478,12 @@ class Interpreter(InterpreterBase): def get_non_matching_default_options(self) -> T.Iterator[T.Tuple[str, str, coredata.UserOption]]: for def_opt_name, def_opt_value in self.project_default_options.items(): cur_opt_value = self.coredata.options.get(def_opt_name) - if cur_opt_value is not None and def_opt_value != cur_opt_value.value: + try: + if cur_opt_value is not None and cur_opt_value.validate_value(def_opt_value) != cur_opt_value.value: + yield (str(def_opt_name), def_opt_value, cur_opt_value) + except mesonlib.MesonException: + # Since the default value does not validate, it cannot be in use + # Report the user-specified value as non-matching yield (str(def_opt_name), def_opt_value, cur_opt_value) def build_func_dict(self): diff --git a/run_unittests.py b/run_unittests.py index 89e4d821f..24a020eb3 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4001,7 +4001,8 @@ class AllPlatformTests(BasePlatformTests): # Verify default values when passing no args that affect the # configuration, and as a bonus, test that --profile-self works. - self.init(testdir, extra_args=['--profile-self', '--fatal-meson-warnings']) + out = self.init(testdir, extra_args=['--profile-self', '--fatal-meson-warnings']) + self.assertNotIn('[default: true]', out) obj = mesonbuild.coredata.load(self.builddir) self.assertEqual(obj.options[OptionKey('default_library')].value, 'static') self.assertEqual(obj.options[OptionKey('warning_level')].value, '1')