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.
@@ -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,
+ 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'])
