Skip to content

Commit 18c1ce7

Browse files
maj0edcbaker
authored andcommitted
mtest: fix building of all test deps for --suite
The previous commit eb1e52a 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`).
1 parent f314f68 commit 18c1ce7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

mesonbuild/mtest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,12 @@ def doit(self) -> int:
18911891
raise RuntimeError('Test harness object can only be used once.')
18921892
self.is_run = True
18931893
tests = self.get_tests()
1894-
rebuild_only_tests = tests if self.options.args else []
1894+
# NOTE: If all tests are selected anyway, we pass
1895+
# an empty list to `rebuild_deps`, which then will execute
1896+
# the "meson-test-prereq" ninja target as a fallback.
1897+
# This prevents situations, where ARG_MAX may overflow
1898+
# if there are many targets.
1899+
rebuild_only_tests = tests if tests != self.tests else []
18951900
if not tests:
18961901
return 0
18971902
if not self.options.no_rebuild and not rebuild_deps(self.ninja, self.options.wd, rebuild_only_tests, self.options.benchmark):

0 commit comments

Comments
 (0)