-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
mtest: fix building of all test deps for --suite #15240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Not sure why allplatformstests.py::AllPlatformTests::test_slice fails but it does seem related to the change. |
Thanks, for having a look at this PR. Output master: Output from this branch The selected tests are actually still correct, but on master, there are the two additional lines from ninja. tests = sorted([ int(x) for x in re.findall(r'\n[ 0-9]+/[0-9]+ test_slice:test-([0-9]*)', output) ])Note, that a match has to start with a newline. Since the first two lines are not there anymore, we don't get a match for the first item (test-1 in this case) and thus the test fails. This leads to the question, why we don't get a message from ninja anymore: On this branch, it is correctly detected, that not all tests are selected, but only a subset. Instead of an empty list we pass the actual list of tests to if not targets:
# We want to build minimal deps, but if the subset of targets have no
# deps then ninja falls back to 'all'.
return TrueI think the latter behaviour is correct and I therefore propose to change the regex in this testcase: tests = sorted([ int(x) for x in re.findall(r'[ 0-9]+/[0-9]+ test_slice:test-([0-9]*)', output) ])Let me know, if you agree, then I push a new commit. And sorry for the wall of text... |
|
I didn't review the regex but the debugging and the consequent wall of text makes me inclined to trust you that it's ok. :) go ahead |
|
Ah, please use rebase -i to place the new regex before your bug fix! Thanks! |
If the first line already conained a match, the former regex didn't catch it correctly, because it was looking for a newline character to detect the start of a line. The new regex is using the proper `^` to match the beginning of a line. For this to work as expected the `re.MULTILINE` flag has to be set.
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`).
f449378 to
b1722a1
Compare
Done. |
Fix building all test targets for meson test --suite
This PR fixes a bug, where all targets are executed, when
meson test --suite <suite>is used.This bug was first observed in meson-1.7.0, but affects all version above. The last correct version was meson-1.6.1.
I created a small example project, which demonstrates the bug: https://github.com/maj0e/meson-test-suite-bug-example
Expected behaviour
When running
meson test --suite <suite>only the targets, that are necessary for the executed tests should be built by meson.Observed behaviour
Meson builds all targets, that depend on any of the tests, even when they are not in the selected test suite.
Implementation
The previous commit eb1e52a introduced a variable
rebuild_only_teststo fix various edge cases in rebuild_deps.In particular, if all tests are selected anyway, rebuild_deps prior to the introduction of
rebuild_only_testswould potentially create a huge list of targets, which may overflow the ARG_MAX limit.For that case
rebuild_only_testswas introduced and is set to an empty list, which means that rebuild_deps falls back to themeson-test-prereqninja target, that already contains the necessary targets.This is wrong, though, when
meson testis executed with the "--suite" option. In that case, the user requested a particular subset of the tests, butrebuild_only_testswill be set to an empty list anyway, which means themeson-test-prereqtarget is executed, which contains the targets for all tests.Instead,
rebuild_only_testsshould only be set to an empty list, when the selected tests are identical to the complete list of available tests:tests == self.testsSince 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).