aboutsummaryrefslogtreecommitdiff
path: root/unittests/internaltests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-23 14:07:57 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-08-27 14:49:23 -0700
commitaa895b383cc726800d7d6e7e540db96dfe9df1f2 (patch)
tree5cc2e66859f342b4afd6372bca4331ad5fae3faa /unittests/internaltests.py
parent4523e9d288d3a97e54d1e971ab9c022616b710e2 (diff)
downloadmeson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.zip
meson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.tar.gz
meson-aa895b383cc726800d7d6e7e540db96dfe9df1f2.tar.bz2
interpreter: Add a helper for checking constrained inputs
This is quite valuable for enum-like inputs, where only a certain set of values is allowed.
Diffstat (limited to 'unittests/internaltests.py')
-rw-r--r--unittests/internaltests.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index a4615d7..daf3efd 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -40,6 +40,7 @@ from mesonbuild.mesonlib import (
LibType, MachineChoice, PerMachine, Version, is_windows, is_osx,
is_cygwin, is_openbsd, search_version, MesonException, OptionKey,
)
+from mesonbuild.interpreter.type_checking import in_set_validator
from mesonbuild.dependencies import PkgConfigDependency
from mesonbuild.programs import ExternalProgram
import mesonbuild.modules.pkgconfig
@@ -1376,7 +1377,7 @@ class InternalTests(unittest.TestCase):
KwargInfo('output', ContainerTypeInfo(dict, str), default={}, deprecated_values={'foo': '0.9'}, since_values={'bar': '1.1'}),
KwargInfo(
'mode', str,
- validator=lambda x: 'Should be one of "clean", "build", "rebuild"' if x not in {'clean', 'build', 'rebuild', 'deprecated', 'since'} else None,
+ validator=in_set_validator({'clean', 'build', 'rebuild', 'deprecated', 'since'}),
deprecated_values={'deprecated': '1.0'},
since_values={'since': '1.1'}),
)