diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py index 87f121e90b0f..d3715aef2e4d 100644 --- a/mesonbuild/interpreter/kwargs.py +++ b/mesonbuild/interpreter/kwargs.py @@ -38,7 +38,6 @@ class BaseTest(TypedDict): """Shared base for the Rust module.""" - args: T.List[T.Union[str, File, build.Target, ExternalProgram]] should_fail: bool timeout: int workdir: T.Optional[str] @@ -48,10 +47,13 @@ class BaseTest(TypedDict): suite: T.List[str] +TestArgs = T.Union[str, File, build.Target, ExternalProgram] + class FuncBenchmark(BaseTest): """Keyword Arguments shared between `test` and `benchmark`.""" + args: T.List[TestArgs] protocol: Literal['exitcode', 'tap', 'gtest', 'rust'] diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index ed34be950065..7519945cfbd8 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -484,9 +484,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus 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, ExternalProgram)), - listify=True, default=[]), +TEST_KWS_NO_ARGS: T.List[KwargInfo] = [ KwargInfo('should_fail', bool, default=False), KwargInfo('timeout', int, default=30), KwargInfo('workdir', (str, NoneType), default=None, @@ -503,6 +501,11 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus KwargInfo('verbose', bool, default=False, since='0.62.0'), ] +TEST_KWS: T.List[KwargInfo] = TEST_KWS_NO_ARGS + [ + KwargInfo('args', ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex, ExternalProgram)), + listify=True, default=[]), +] + # Cannot have a default value because we need to check that rust_crate_type and # rust_abi are mutually exclusive. RUST_CRATE_TYPE_KW: KwargInfo[T.Union[str, None]] = KwargInfo( diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index ceba6470632a..3130b3214066 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -34,8 +34,9 @@ from typing_extensions import TypedDict, Literal - class FuncTest(_kwargs.BaseTest): + class FuncTest(TypedDict, _kwargs.BaseTest): + args: T.List[_kwargs.TestArgs] dependencies: T.List[T.Union[Dependency, ExternalLibrary]] is_parallel: bool link_with: T.List[LibTypes]