From 1dcde9da61205f762ee4f1880732b18ee7360389 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 21 Jul 2021 09:28:25 -0400 Subject: [PATCH] modules: Add API to add test This fix kwargs not going through typed_kwargs() decorator that sets defaults. Fixes: #9009 --- mesonbuild/modules/__init__.py | 13 ++++++++++++- mesonbuild/modules/gnome.py | 6 ++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 19de1bd1e..12bb73acf 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -18,7 +18,7 @@ import os import typing as T -from .. import build +from .. import build, mesonlib from ..mesonlib import relpath, HoldableObject from ..interpreterbase.decorators import noKwargs, noPosargs @@ -92,6 +92,17 @@ class ModuleState: wanted: T.Optional[str] = None) -> 'ExternalProgram': return self._interpreter.find_program_impl(prog, required=required, version_func=version_func, wanted=wanted) + def test(self, args: T.Tuple[str, T.Union[build.Executable, build.Jar, 'ExternalProgram', mesonlib.File]], + workdir: T.Optional[str] = None, + env: T.Union[T.List[str], T.Dict[str, str], str] = None, + depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]] = None) -> None: + kwargs = {'workdir': workdir, + 'env': env, + 'depends': depends, + } + # TODO: Use interpreter internal API, but we need to go through @typed_kwargs + self._interpreter.func_test(self.node, args, kwargs) + class ModuleObject(HoldableObject): """Base class for all objects returned by modules diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 3cc8ebdc8..b138f5582 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -1136,10 +1136,8 @@ class GnomeModule(ExtensionModule): check_env = ['DOC_MODULE=' + modulename, 'DOC_MAIN_SGML_FILE=' + main_file] check_args = [targetname + '-check', check_cmd] - check_kwargs = {'env': check_env, - 'workdir': os.path.join(state.environment.get_build_dir(), state.subdir), - 'depends': custom_target} - self.interpreter.add_test(state.current_node, check_args, check_kwargs, True) + check_workdir = os.path.join(state.environment.get_build_dir(), state.subdir) + state.test(check_args, env=check_env, workdir=check_workdir, depends=custom_target) res = [custom_target, alias_target] if kwargs.get('install', True): res.append(state.backend.get_executable_serialisation(command + args))