Skip to content

Commit b2c2549

Browse files
committed
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.
1 parent 8d19bec commit b2c2549

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mesonbuild/interpreter.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,7 +4122,7 @@ def unpack_env_kwarg(self, kwargs) -> build.EnvironmentVariables:
41224122
env = env.held_object
41234123
return env
41244124

4125-
def add_test(self, node, args, kwargs, is_base_test):
4125+
def make_test(self, node: mparser.BaseNode, args: T.List, kwargs: T.Dict[str, T.Any]):
41264126
if len(args) != 2:
41274127
raise InterpreterException('test expects 2 arguments, {} given'.format(len(args)))
41284128
name = args[0]
@@ -4176,14 +4176,17 @@ def add_test(self, node, args, kwargs, is_base_test):
41764176
priority = kwargs.get('priority', 0)
41774177
if not isinstance(priority, int):
41784178
raise InterpreterException('Keyword argument priority must be an integer.')
4179-
t = Test(name, prj, suite, exe.held_object, depends, par, cmd_args,
4180-
env, should_fail, timeout, workdir, protocol, priority)
4179+
return Test(name, prj, suite, exe.held_object, depends, par, cmd_args,
4180+
env, should_fail, timeout, workdir, protocol, priority)
4181+
4182+
def add_test(self, node: mparser.BaseNode, args: T.List, kwargs: T.Dict[str, T.Any], is_base_test: bool):
4183+
t = self.make_test(node, args, kwargs)
41814184
if is_base_test:
41824185
self.build.tests.append(t)
4183-
mlog.debug('Adding test', mlog.bold(name, True))
4186+
mlog.debug('Adding test', mlog.bold(t.name, True))
41844187
else:
41854188
self.build.benchmarks.append(t)
4186-
mlog.debug('Adding benchmark', mlog.bold(name, True))
4189+
mlog.debug('Adding benchmark', mlog.bold(t.name, True))
41874190

41884191
@FeatureNewKwargs('install_headers', '0.47.0', ['install_mode'])
41894192
@permittedKwargs(permitted_kwargs['install_headers'])

0 commit comments

Comments
 (0)