interpreter: move TEST_KW from interpreter.py to type_checking.py

Since it's also used in the rust module, it should be in a common place.
Also rename from `TEST_KWARGS` to `TEST_KWS`, which is more in line with
the `*_KW` naming scheme used in the type_checking module.
pull/11024/head
Dylan Baker 2 years ago committed by Eli Schwartz
parent 99dfc988eb
commit 010f525cc5
  1. 24
      mesonbuild/interpreter/interpreter.py
  2. 19
      mesonbuild/interpreter/type_checking.py
  3. 4
      mesonbuild/modules/rust.py

@ -83,6 +83,7 @@ from .type_checking import (
REQUIRED_KW, REQUIRED_KW,
SOURCES_KW, SOURCES_KW,
VARIABLES_KW, VARIABLES_KW,
TEST_KWS,
NoneType, NoneType,
in_set_validator, in_set_validator,
env_convertor_with_method env_convertor_with_method
@ -223,25 +224,6 @@ known_build_target_kwargs = (
{'target_type'} {'target_type'}
) )
TEST_KWARGS: T.List[KwargInfo] = [
KwargInfo('args', ContainerTypeInfo(list, (str, mesonlib.File, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex)),
listify=True, default=[]),
KwargInfo('should_fail', bool, default=False),
KwargInfo('timeout', int, default=30),
KwargInfo('workdir', (str, NoneType), default=None,
validator=lambda x: 'must be an absolute path' if not os.path.isabs(x) else None),
KwargInfo('protocol', str,
default='exitcode',
validator=in_set_validator({'exitcode', 'tap', 'gtest', 'rust'}),
since_values={'gtest': '0.55.0', 'rust': '0.57.0'}),
KwargInfo('priority', int, default=0, since='0.52.0'),
# TODO: env needs reworks of the way the environment variable holder itself works probably
ENV_KW,
DEPENDS_KW.evolve(since='0.46.0'),
KwargInfo('suite', ContainerTypeInfo(list, str), listify=True, default=['']), # yes, a list of empty string
KwargInfo('verbose', bool, default=False, since='0.62.0'),
]
class InterpreterRuleRelaxation(Enum): class InterpreterRuleRelaxation(Enum):
''' Defines specific relaxations of the Meson rules. ''' Defines specific relaxations of the Meson rules.
@ -2050,14 +2032,14 @@ class Interpreter(InterpreterBase, HoldableObject):
return gen return gen
@typed_pos_args('benchmark', str, (build.Executable, build.Jar, ExternalProgram, mesonlib.File)) @typed_pos_args('benchmark', str, (build.Executable, build.Jar, ExternalProgram, mesonlib.File))
@typed_kwargs('benchmark', *TEST_KWARGS) @typed_kwargs('benchmark', *TEST_KWS)
def func_benchmark(self, node: mparser.BaseNode, def func_benchmark(self, node: mparser.BaseNode,
args: T.Tuple[str, T.Union[build.Executable, build.Jar, ExternalProgram, mesonlib.File]], args: T.Tuple[str, T.Union[build.Executable, build.Jar, ExternalProgram, mesonlib.File]],
kwargs: 'kwtypes.FuncBenchmark') -> None: kwargs: 'kwtypes.FuncBenchmark') -> None:
self.add_test(node, args, kwargs, False) self.add_test(node, args, kwargs, False)
@typed_pos_args('test', str, (build.Executable, build.Jar, ExternalProgram, mesonlib.File)) @typed_pos_args('test', str, (build.Executable, build.Jar, ExternalProgram, mesonlib.File))
@typed_kwargs('test', *TEST_KWARGS, KwargInfo('is_parallel', bool, default=True)) @typed_kwargs('test', *TEST_KWS, KwargInfo('is_parallel', bool, default=True))
def func_test(self, node: mparser.BaseNode, def func_test(self, node: mparser.BaseNode,
args: T.Tuple[str, T.Union[build.Executable, build.Jar, ExternalProgram, mesonlib.File]], args: T.Tuple[str, T.Union[build.Executable, build.Jar, ExternalProgram, mesonlib.File]],
kwargs: 'kwtypes.FuncTest') -> None: kwargs: 'kwtypes.FuncTest') -> None:

@ -448,3 +448,22 @@ VARIABLES_KW: KwargInfo[T.Dict[str, str]] = KwargInfo(
) )
PRESERVE_PATH_KW: KwargInfo[bool] = KwargInfo('preserve_path', bool, default=False, since='0.63.0') PRESERVE_PATH_KW: KwargInfo[bool] = KwargInfo('preserve_path', bool, default=False, since='0.63.0')
TEST_KWS: T.List[KwargInfo] = [
KwargInfo('args', ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex)),
listify=True, default=[]),
KwargInfo('should_fail', bool, default=False),
KwargInfo('timeout', int, default=30),
KwargInfo('workdir', (str, NoneType), default=None,
validator=lambda x: 'must be an absolute path' if not os.path.isabs(x) else None),
KwargInfo('protocol', str,
default='exitcode',
validator=in_set_validator({'exitcode', 'tap', 'gtest', 'rust'}),
since_values={'gtest': '0.55.0', 'rust': '0.57.0'}),
KwargInfo('priority', int, default=0, since='0.52.0'),
# TODO: env needs reworks of the way the environment variable holder itself works probably
ENV_KW,
DEPENDS_KW.evolve(since='0.46.0'),
KwargInfo('suite', ContainerTypeInfo(list, str), listify=True, default=['']), # yes, a list of empty string
KwargInfo('verbose', bool, default=False, since='0.62.0'),
]

@ -19,7 +19,7 @@ from . import ExtensionModule, ModuleReturnValue, ModuleInfo
from .. import mlog from .. import mlog
from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, StructuredSources from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget, StructuredSources
from ..dependencies import Dependency, ExternalLibrary from ..dependencies import Dependency, ExternalLibrary
from ..interpreter.interpreter import TEST_KWARGS, OUTPUT_KW from ..interpreter.type_checking import TEST_KWS, OUTPUT_KW
from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, typed_kwargs, typed_pos_args, noPosargs
from ..mesonlib import File from ..mesonlib import File
@ -63,7 +63,7 @@ class RustModule(ExtensionModule):
@typed_pos_args('rust.test', str, BuildTarget) @typed_pos_args('rust.test', str, BuildTarget)
@typed_kwargs( @typed_kwargs(
'rust.test', 'rust.test',
*TEST_KWARGS, *TEST_KWS,
KwargInfo('is_parallel', bool, default=False), KwargInfo('is_parallel', bool, default=False),
KwargInfo( KwargInfo(
'dependencies', 'dependencies',

Loading…
Cancel
Save