diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-23 14:07:57 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-08-27 14:49:23 -0700 |
commit | aa895b383cc726800d7d6e7e540db96dfe9df1f2 (patch) | |
tree | 5cc2e66859f342b4afd6372bca4331ad5fae3faa /mesonbuild/interpreter/interpreter.py | |
parent | 4523e9d288d3a97e54d1e971ab9c022616b710e2 (diff) | |
download | meson-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 'mesonbuild/interpreter/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index c716c85..5b03e7e 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -55,6 +55,7 @@ from .type_checking import ( LANGUAGE_KW, NATIVE_KW, REQUIRED_KW, + in_set_validator, ) from pathlib import Path @@ -181,7 +182,7 @@ TEST_KWARGS: T.List[KwargInfo] = [ validator=lambda x: 'must be an absolute path' if not os.path.isabs(x) else None), KwargInfo('protocol', str, default='exitcode', - validator=lambda x: 'value must be one of "exitcode", "tap", "gtest", "rust"' if x not in {'exitcode', 'tap', 'gtest', 'rust'} else None, + validator=in_set_validator({'exitcode', 'tap', 'gtest', 'rust'}), since_values={'gtest': '0.55.0', 'rust': '0.57.0'}), KwargInfo('depends', ContainerTypeInfo(list, (build.CustomTarget, build.BuildTarget)), listify=True, default=[], since='0.46.0'), |