From b2c2549b93a8001d8a6d9d6da1ce756645e59160 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 21 Oct 2020 16:01:00 -0700 Subject: [PATCH] interpreter: split code that creates a Test instance For modules to make use of, as they're not allowed to modify the Build instance directly. --- mesonbuild/interpreter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7b8a7f860..6e0423579 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -4122,7 +4122,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self env = env.held_object return env - def add_test(self, node, args, kwargs, is_base_test): + 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))) name = args[0] @@ -4176,14 +4176,17 @@ This will become a hard error in the future.''' % kwargs['input'], location=self priority = kwargs.get('priority', 0) if not isinstance(priority, int): raise InterpreterException('Keyword argument priority must be an integer.') - t = Test(name, prj, suite, exe.held_object, depends, par, cmd_args, - env, should_fail, timeout, workdir, protocol, priority) + return Test(name, prj, suite, exe.held_object, depends, par, cmd_args, + env, should_fail, timeout, workdir, protocol, priority) + + def add_test(self, node: mparser.BaseNode, args: T.List, kwargs: T.Dict[str, T.Any], is_base_test: bool): + t = self.make_test(node, args, kwargs) if is_base_test: self.build.tests.append(t) - mlog.debug('Adding test', mlog.bold(name, True)) + mlog.debug('Adding test', mlog.bold(t.name, True)) else: self.build.benchmarks.append(t) - mlog.debug('Adding benchmark', mlog.bold(name, True)) + mlog.debug('Adding benchmark', mlog.bold(t.name, True)) @FeatureNewKwargs('install_headers', '0.47.0', ['install_mode']) @permittedKwargs(permitted_kwargs['install_headers'])