aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-10-14 18:19:15 +0200
committerDylan Baker <dylan@pnwbakers.com>2021-12-06 13:27:12 -0800
commit18408f82d1ed2f04ef069e8e5836449a9cc5c355 (patch)
treec2a1e3db41d0aa4a1645fa49ac44409bca1b6120
parent2ef06618e2252fc5fb9262792a3bd544ec182ec5 (diff)
downloadmeson-18408f82d1ed2f04ef069e8e5836449a9cc5c355.zip
meson-18408f82d1ed2f04ef069e8e5836449a9cc5c355.tar.gz
meson-18408f82d1ed2f04ef069e8e5836449a9cc5c355.tar.bz2
allow passing a CustomTargetIndex as argument to a test
Fixes: #7585 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/backend/backends.py8
-rw-r--r--mesonbuild/interpreter/interpreter.py2
-rw-r--r--test cases/common/245 custom target index source/meson.build2
-rw-r--r--test cases/failing/116 run_target in test/test.json2
4 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 8633f23..718f54c 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -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]
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index ae6be3b..2a68aa0 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -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),
diff --git a/test cases/common/245 custom target index source/meson.build b/test cases/common/245 custom target index source/meson.build
index c7efbd8..c8087dd 100644
--- a/test cases/common/245 custom target index source/meson.build
+++ b/test cases/common/245 custom target index source/meson.build
@@ -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)
diff --git a/test cases/failing/116 run_target in test/test.json b/test cases/failing/116 run_target in test/test.json
index e08aa03..961c1e4 100644
--- a/test cases/failing/116 run_target in test/test.json
+++ b/test cases/failing/116 run_target in test/test.json
@@ -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]"
}
]
}