From 88071fa11914ee8bd4c4ec68f4fbdfdf922ed2b7 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 6 Jan 2019 02:58:53 +0200 Subject: [PATCH] Calculate target paths correctly when workdir is set. Closes #2681. --- mesonbuild/backend/backends.py | 9 ++++++++- test cases/common/97 test workdir/meson.build | 2 ++ test cases/common/97 test workdir/subdir/checker.py | 5 +++++ test cases/common/97 test workdir/subdir/meson.build | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 test cases/common/97 test workdir/subdir/checker.py create mode 100644 test cases/common/97 test workdir/subdir/meson.build diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index e8adc99de009..23923a362c34 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -725,7 +725,7 @@ def write_test_serialisation(self, tests, datafile): elif isinstance(a, str): cmd_args.append(a) elif isinstance(a, build.Target): - cmd_args.append(self.get_target_filename(a)) + cmd_args.append(self.construct_target_rel_path(a, t.workdir)) else: raise MesonException('Bad object in test command.') ts = TestSerialisation(t.get_name(), t.project_name, t.suite, cmd, is_cross, @@ -734,6 +734,13 @@ def write_test_serialisation(self, tests, datafile): arr.append(ts) pickle.dump(arr, datafile) + def construct_target_rel_path(self, a, workdir): + 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 generate_depmf_install(self, d): if self.build.dep_manifest_name is None: return diff --git a/test cases/common/97 test workdir/meson.build b/test cases/common/97 test workdir/meson.build index 1323a17a93d4..a8290f7e056f 100644 --- a/test cases/common/97 test workdir/meson.build +++ b/test cases/common/97 test workdir/meson.build @@ -4,3 +4,5 @@ exe = executable('opener', 'opener.c') test('basic', exe, workdir : meson.source_root()) test('shouldfail', exe, should_fail : true) + +subdir('subdir') diff --git a/test cases/common/97 test workdir/subdir/checker.py b/test cases/common/97 test workdir/subdir/checker.py new file mode 100755 index 000000000000..66e287d4ac43 --- /dev/null +++ b/test cases/common/97 test workdir/subdir/checker.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +import sys + +data = open(sys.argv[1], 'rb').read() diff --git a/test cases/common/97 test workdir/subdir/meson.build b/test cases/common/97 test workdir/subdir/meson.build new file mode 100644 index 000000000000..687a1cf23860 --- /dev/null +++ b/test cases/common/97 test workdir/subdir/meson.build @@ -0,0 +1,4 @@ +exe2 = executable('dummy', '../opener.c') +test('subdir', find_program('checker.py'), + workdir : meson.source_root(), + args: [exe2])