From 18c1ce716b8fe43cce090daa851b64cbbbdbd532 Mon Sep 17 00:00:00 2001 From: maj0e <57637846+maj0e@users.noreply.github.com> Date: Wed, 12 Nov 2025 13:14:26 +0100 Subject: 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`). --- mesonbuild/mtest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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): -- cgit v1.2.3