Merge pull request #9565 from bonzini/invalid-run-target
reject run_target in test or install script arguments
This commit is contained in:
commit
5b08fd4b33
|
@ -192,7 +192,7 @@ known_build_target_kwargs = (
|
|||
)
|
||||
|
||||
TEST_KWARGS: T.List[KwargInfo] = [
|
||||
KwargInfo('args', ContainerTypeInfo(list, (str, mesonlib.File, build.Target)),
|
||||
KwargInfo('args', ContainerTypeInfo(list, (str, mesonlib.File, build.BuildTarget, build.CustomTarget)),
|
||||
listify=True, default=[]),
|
||||
KwargInfo('should_fail', bool, default=False),
|
||||
KwargInfo('timeout', int, default=30),
|
||||
|
|
|
@ -95,9 +95,9 @@ class MesonMain(MesonInterpreterObject):
|
|||
|
||||
def _process_script_args(
|
||||
self, name: str, args: T.Sequence[T.Union[
|
||||
str, mesonlib.File, build.Target,
|
||||
str, mesonlib.File, build.BuildTarget, build.CustomTarget,
|
||||
build.CustomTargetIndex,
|
||||
ExternalProgram, build.Executable,
|
||||
ExternalProgram,
|
||||
]], allow_built: bool = False) -> T.List[str]:
|
||||
script_args = [] # T.List[str]
|
||||
new = False
|
||||
|
@ -107,7 +107,7 @@ class MesonMain(MesonInterpreterObject):
|
|||
elif isinstance(a, mesonlib.File):
|
||||
new = True
|
||||
script_args.append(a.rel_to_builddir(self.interpreter.environment.source_dir))
|
||||
elif isinstance(a, (build.Target, build.CustomTargetIndex)):
|
||||
elif isinstance(a, (build.BuildTarget, build.CustomTarget, build.CustomTargetIndex)):
|
||||
if not allow_built:
|
||||
raise InterpreterException(f'Arguments to {name} cannot be built')
|
||||
new = True
|
||||
|
@ -135,7 +135,7 @@ class MesonMain(MesonInterpreterObject):
|
|||
@typed_pos_args(
|
||||
'meson.add_install_script',
|
||||
(str, mesonlib.File, build.Executable, ExternalProgram),
|
||||
varargs=(str, mesonlib.File, build.Target, build.CustomTargetIndex, ExternalProgram)
|
||||
varargs=(str, mesonlib.File, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, ExternalProgram)
|
||||
)
|
||||
@typed_kwargs(
|
||||
'meson.add_install_script',
|
||||
|
@ -145,7 +145,7 @@ class MesonMain(MesonInterpreterObject):
|
|||
def add_install_script_method(
|
||||
self,
|
||||
args: T.Tuple[T.Union[str, mesonlib.File, build.Executable, ExternalProgram],
|
||||
T.List[T.Union[str, mesonlib.File, build.Target, build.CustomTargetIndex, ExternalProgram]]],
|
||||
T.List[T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, ExternalProgram]]],
|
||||
kwargs: 'AddInstallScriptKW') -> None:
|
||||
if isinstance(args[0], mesonlib.File):
|
||||
FeatureNew.single_use('Passing file object to script parameter of add_install_script',
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
project('trivial test', 'c')
|
||||
exe = executable('trivialprog', 'trivial.c')
|
||||
runt = run_target('invalid', command: ['echo', 'run_target'])
|
||||
test('runtest', exe, args: runt)
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"stdout": [
|
||||
{
|
||||
"line": "test cases/failing/116 run_target in test/meson.build:4:0: ERROR: test keyword argument 'args' was of type 'list' but should have been list[str,File,BuildTarget,CustomTarget]"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#include<stdio.h>
|
||||
|
||||
int main(void) {
|
||||
printf("Trivial test is working.\n");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
project('trivial test', 'c')
|
||||
exe = executable('trivialprog', 'trivial.c')
|
||||
runt = run_target('invalid', command: ['echo', 'run_target'])
|
||||
meson.add_install_script(exe, runt)
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"stdout": [
|
||||
{
|
||||
"line": "test cases/failing/117 run_target in add_install_script/meson.build:4:6: ERROR: meson.add_install_script argument 2 was of type \"RunTarget\" but should have been one of: \"str\", \"File\", \"BuildTarget\", \"CustomTarget\", \"CustomTargetIndex\", \"ExternalProgram\""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
FILE *fp = fopen(argv[1], "r");
|
||||
if (fp == NULL) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue