aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-10-14 18:17:25 +0200
committerDylan Baker <dylan@pnwbakers.com>2021-12-06 13:27:12 -0800
commit2ef06618e2252fc5fb9262792a3bd544ec182ec5 (patch)
tree40979088dce8bec0dafa02412a96b893de60eb32 /mesonbuild
parent185c4e3c95f32de429179b025ef86785b06bc3de (diff)
downloadmeson-2ef06618e2252fc5fb9262792a3bd544ec182ec5.zip
meson-2ef06618e2252fc5fb9262792a3bd544ec182ec5.tar.gz
meson-2ef06618e2252fc5fb9262792a3bd544ec182ec5.tar.bz2
pass all outputs of a custom_target as arguments to a test
Meson was passing only the first output and warning about it. To do this easily, refactor construct_target_rel_path to return a list. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index bb04fea..8633f23 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -1143,13 +1143,8 @@ class Backend:
cmd_args.append(a)
elif isinstance(a, str):
cmd_args.append(a)
- elif isinstance(a, build.Executable):
- p = self.construct_target_rel_path(a, t.workdir)
- if p == a.get_filename():
- p = './' + p
- cmd_args.append(p)
elif isinstance(a, build.Target):
- cmd_args.append(self.construct_target_rel_path(a, t.workdir))
+ cmd_args.extend(self.construct_target_rel_paths(a, t.workdir))
else:
raise MesonException('Bad object in test command.')
ts = TestSerialisation(t.get_name(), t.project_name, t.suite, cmd, is_cross,
@@ -1166,12 +1161,24 @@ 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_path(self, a: build.Target, workdir: T.Optional[str]) -> str:
- if workdir is None:
- return self.get_target_filename(a)
- assert os.path.isabs(workdir)
- abs_path = self.get_target_filename_abs(a)
- return os.path.relpath(abs_path, workdir)
+ def construct_target_rel_paths(self, t: build.Target, 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:
+ target_dir = target_dir or '.'
+
+ if isinstance(t, build.BuildTarget):
+ outputs = [t.get_filename()]
+ else:
+ assert isinstance(t, build.CustomTarget)
+ outputs = t.get_outputs()
+
+ outputs = [os.path.join(target_dir, x) for x in outputs]
+ if workdir is not None:
+ assert os.path.isabs(workdir)
+ outputs = [os.path.join(self.environment.get_build_dir(), x) for x in outputs]
+ outputs = [os.path.relpath(x, workdir) for x in outputs]
+ return outputs
def generate_depmf_install(self, d: InstallData) -> None:
if self.build.dep_manifest_name is None: