aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreter.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-06-08 12:09:43 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-06-14 12:30:02 -0700
commit86704261a7227dc1681aa544e6d44e1b2f941fe1 (patch)
tree319aa545cc0bc50ab9ab5d852e344d139853e911 /mesonbuild/interpreter/interpreter.py
parent5bb75dc3af4d1b91af024e70d9cb2432886eb959 (diff)
downloadmeson-86704261a7227dc1681aa544e6d44e1b2f941fe1.zip
meson-86704261a7227dc1681aa544e6d44e1b2f941fe1.tar.gz
meson-86704261a7227dc1681aa544e6d44e1b2f941fe1.tar.bz2
interpreter: use typed_pos_args for func_test and func_benchmark
Requires a few small changes to the Rust module, as it calls `func_test`
Diffstat (limited to 'mesonbuild/interpreter/interpreter.py')
-rw-r--r--mesonbuild/interpreter/interpreter.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 65ad321..5b58f2c 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1955,7 +1955,10 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
@FeatureNewKwargs('benchmark', '0.46.0', ['depends'])
@FeatureNewKwargs('benchmark', '0.52.0', ['priority'])
@permittedKwargs(permitted_test_kwargs)
- def func_benchmark(self, node, args, kwargs):
+ @typed_pos_args('benchmark', str, (ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File))
+ def func_benchmark(self, node: mparser.FunctionNode,
+ args: T.Tuple[str, T.Union[ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File]],
+ kwargs) -> None:
# is_parallel isn't valid here, so make sure it isn't passed
if 'is_parallel' in kwargs:
del kwargs['is_parallel']
@@ -1964,7 +1967,10 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
@FeatureNewKwargs('test', '0.46.0', ['depends'])
@FeatureNewKwargs('test', '0.52.0', ['priority'])
@permittedKwargs(permitted_test_kwargs | {'is_parallel'})
- def func_test(self, node, args, kwargs):
+ @typed_pos_args('test', str, (ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File))
+ def func_test(self, node: mparser.FunctionNode,
+ args: T.Tuple[str, T.Union[ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File]],
+ kwargs) -> None:
if kwargs.get('protocol') == 'gtest':
FeatureNew.single_use('"gtest" protocol for tests', '0.55.0', self.subproject)
self.add_test(node, args, kwargs, True)
@@ -1983,22 +1989,18 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
env = env.held_object
return env
- def make_test(self, node: mparser.BaseNode, args: T.List, kwargs: T.Dict[str, T.Any]):
- if len(args) != 2:
- raise InterpreterException('test expects 2 arguments, {} given'.format(len(args)))
+ def make_test(self, node: mparser.FunctionNode,
+ args: T.Tuple[str, T.Union[ExecutableHolder, JarHolder, ExternalProgramHolder, mesonlib.File]],
+ kwargs: T.Dict[str, T.Any]) -> Test:
name = args[0]
- if not isinstance(name, str):
- raise InterpreterException('First argument of test must be a string.')
if ':' in name:
mlog.deprecation(f'":" is not allowed in test name "{name}", it has been replaced with "_"',
location=node)
name = name.replace(':', '_')
exe = args[1]
- if not isinstance(exe, (ExecutableHolder, JarHolder, ExternalProgramHolder)):
- if isinstance(exe, mesonlib.File):
- exe = self.func_find_program(node, args[1], {})
- else:
- raise InterpreterException('Second argument must be executable.')
+ if isinstance(exe, mesonlib.File):
+ exe = self.func_find_program(node, args[1], {})
+
par = kwargs.get('is_parallel', True)
if not isinstance(par, bool):
raise InterpreterException('Keyword argument is_parallel must be a boolean.')