summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaj0e <57637846+maj0e@users.noreply.github.com>2025-11-12 13:14:26 +0100
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 09:15:03 -0800
commit18c1ce716b8fe43cce090daa851b64cbbbdbd532 (patch)
tree32080ad764954cea2c6901a8ade78f94e6f02721
parentf314f68f9f05f31b686b42575c373d4a42ec2d5e (diff)
downloadmeson-18c1ce716b8fe43cce090daa851b64cbbbdbd532.tar.gz
mtest: fix building of all test deps for --suite
The previous commit eb1e52afa142fc0f38260a9cb3413f2bd63b1675 introduced a variable `rebuild_only_tests` to fix various edge cases in rebuild_deps. In particular, if all tests are selected anyway, rebuild_deps prior to the introduction of `rebuild_only_tests` would potentially create a huge list of targets, which may overflow the ARG_MAX limit. For that case `rebuild_only_tests` was introduced and is set to an empty list, which means that rebuild_deps falls back to the `meson-test-prereq` ninja target, that already contains the necessary targets. This is wrong, though, when `meson test` is executed with the "--suite" option. In that case, the user requested a particular subset of the tests, but `rebuild_only_tests` will be set to an empty list anyway, which means the `meson-test-prereq` target is executed, which contains the targets for all tests. Instead, `rebuild_only_tests` should only be set to an empty list, when the selected tests are identical to the complete list of available tests: `tests == self.tests` Since after this commit we compare directly to the result of `self.get_tests()`, this will do the correct thing for all other options, which change or filter the list of selected tests (e.g. `self.options.args`, `self.options.slice`).
-rw-r--r--mesonbuild/mtest.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 196638857..95ca11d5c 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -1891,7 +1891,12 @@ class TestHarness:
raise RuntimeError('Test harness object can only be used once.')
self.is_run = True
tests = self.get_tests()
- rebuild_only_tests = tests if self.options.args else []
+ # NOTE: If all tests are selected anyway, we pass
+ # an empty list to `rebuild_deps`, which then will execute
+ # the "meson-test-prereq" ninja target as a fallback.
+ # This prevents situations, where ARG_MAX may overflow
+ # if there are many targets.
+ rebuild_only_tests = tests if tests != self.tests else []
if not tests:
return 0
if not self.options.no_rebuild and not rebuild_deps(self.ninja, self.options.wd, rebuild_only_tests, self.options.benchmark):