allow passing a CustomTargetIndex as argument to a test

Fixes: #7585
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/7897/head
Paolo Bonzini 3 years ago committed by Dylan Baker
parent 2ef06618e2
commit 18408f82d1
  1. 8
      mesonbuild/backend/backends.py
  2. 2
      mesonbuild/interpreter/interpreter.py
  3. 2
      test cases/common/245 custom target index source/meson.build
  4. 2
      test cases/failing/116 run_target in test/test.json

@ -1135,6 +1135,8 @@ class Backend:
for a in t.cmd_args:
if isinstance(a, build.Target):
depends.add(a)
elif isinstance(a, build.CustomTargetIndex):
depends.add(a.target)
if isinstance(a, build.BuildTarget):
extra_paths += self.determine_windows_extra_paths(a, [])
@ -1143,7 +1145,7 @@ class Backend:
cmd_args.append(a)
elif isinstance(a, str):
cmd_args.append(a)
elif isinstance(a, build.Target):
elif isinstance(a, (build.Target, build.CustomTargetIndex)):
cmd_args.extend(self.construct_target_rel_paths(a, t.workdir))
else:
raise MesonException('Bad object in test command.')
@ -1161,7 +1163,7 @@ class Backend:
def write_test_serialisation(self, tests: T.List['Test'], datafile: T.BinaryIO) -> None:
pickle.dump(self.create_test_serialisation(tests), datafile)
def construct_target_rel_paths(self, t: build.Target, workdir: T.Optional[str]) -> T.List[str]:
def construct_target_rel_paths(self, t: T.Union[build.Target, build.CustomTargetIndex], workdir: T.Optional[str]) -> T.List[str]:
target_dir = self.get_target_dir(t)
# ensure that test executables can be run when passed as arguments
if isinstance(t, build.Executable) and workdir is None:
@ -1170,7 +1172,7 @@ class Backend:
if isinstance(t, build.BuildTarget):
outputs = [t.get_filename()]
else:
assert isinstance(t, build.CustomTarget)
assert isinstance(t, (build.CustomTarget, build.CustomTargetIndex))
outputs = t.get_outputs()
outputs = [os.path.join(target_dir, x) for x in outputs]

@ -199,7 +199,7 @@ known_build_target_kwargs = (
)
TEST_KWARGS: T.List[KwargInfo] = [
KwargInfo('args', ContainerTypeInfo(list, (str, mesonlib.File, build.BuildTarget, build.CustomTarget)),
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),

@ -47,5 +47,5 @@ exe_together = executable('exe_together',
)
# also cover passing custom target to tests as arguments
test('exe_separate', exe_separate, args: ['unused1', 'unused2'])
test('exe_separate', exe_separate, args: [gen_c, gen_h])
test('exe_together', exe_together, args: gen)

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/116 run_target in test/meson.build:4:0: ERROR: test keyword argument 'args' was of type array[RunTarget] but should have been array[str | File | BuildTarget | CustomTarget]"
"line": "test cases/failing/116 run_target in test/meson.build:4:0: ERROR: test keyword argument 'args' was of type array[RunTarget] but should have been array[str | File | BuildTarget | CustomTarget | CustomTargetIndex]"
}
]
}

Loading…
Cancel
Save