diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2019-10-08 11:02:00 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-11-07 17:32:03 +0530 |
commit | 5b5e0311f011e74de17c97a06dae757b2cd2d81d (patch) | |
tree | 14ed25371e3f2449741cd00c416d6ab210283d1c | |
parent | e550b5d21d999eaeb5b884c3adea276791e0a4f5 (diff) | |
download | meson-5b5e0311f011e74de17c97a06dae757b2cd2d81d.zip meson-5b5e0311f011e74de17c97a06dae757b2cd2d81d.tar.gz meson-5b5e0311f011e74de17c97a06dae757b2cd2d81d.tar.bz2 |
Fix `if not disabler()` case
Closes: #6010
-rw-r--r-- | mesonbuild/interpreterbase.py | 2 | ||||
-rw-r--r-- | test cases/common/163 disabler/meson.build | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 082515c..5c83900 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -500,6 +500,8 @@ class InterpreterBase: def evaluate_notstatement(self, cur): v = self.evaluate_statement(cur.value) + if is_disabler(v): + return v if not isinstance(v, bool): raise InterpreterException('Argument to "not" is not a boolean.') return not v diff --git a/test cases/common/163 disabler/meson.build b/test cases/common/163 disabler/meson.build index 5eb24ba..8da2a0b 100644 --- a/test cases/common/163 disabler/meson.build +++ b/test cases/common/163 disabler/meson.build @@ -76,3 +76,25 @@ else has_not_changed = true endif assert(has_not_changed, 'App has changed.') + +if_is_disabled = true +if disabler() + if_is_disabled = false +else + if_is_disabled = false +endif +assert(if_is_disabled, 'Disabler in "if condition" must skip both blocks') + +if not disabler() + if_is_disabled = false +else + if_is_disabled = false +endif +assert(if_is_disabled, 'Disabler in "if not condition" must skip both blocks') + +if disabler() == 1 + if_is_disabled = false +else + if_is_disabled = false +endif +assert(if_is_disabled, 'Disabler in "if a==b" must skip both blocks') |