-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
mtest: fix rebuilding correct target list before running tests #10413
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Test targets no longer built by default | ||
|
||
`meson test` and the `ninja all` rule have been reworked to no longer force | ||
unnecessary rebuilds. | ||
|
||
`meson test` was invoking `ninja all` due to a bug if the chosen set of tests | ||
had no build dependencies. The behavior is now the same as when tests do have | ||
build dependencies, i.e. to only build the actual set of targets that are used | ||
by the test. This change could cause failures when upgrading to Meson 1.7.0, if | ||
the dependencies are not specified correctly in meson.build. Using `ninja test` | ||
has always been guaranteed to "do the right thing" and rebuild `all` as well; | ||
this continues to work. | ||
|
||
`ninja all` does not rebuild all tests anymore; it should be noted that this | ||
change means test programs are no longer guaranteed to have been built, | ||
depending on whether those test programs were *also* defined to build by | ||
default / marked as installable. This avoids building test-only binaries as | ||
part of installing the project (`ninja && ninja install`), which is unnecessary | ||
and has no use case. | ||
|
||
Some users might have been relying on the "all" target building test | ||
dependencies in combination with `meson test --no-rebuild` in order to skip | ||
calling out to ninja when running tests. This might break with this change | ||
because, when given `--no-rebuild`, Meson provides no guarantee that test | ||
dependencies are present and up to date. The recommended workflow is to use | ||
either `ninja test` or `ninja && meson test` but, if you wish to build test | ||
programs and dependencies in a separate stage, you can use for example `ninja | ||
all meson-test-prereq meson-benchmark-prereq` before `meson test --no-rebuild`. | ||
These prereq targets have been available since meson 0.63.0. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int main(void) { return 0 ; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
project('underspecified deps', 'c') | ||
|
||
runner = find_program('runner.py') | ||
exe1 = executable('main1', 'main.c') | ||
exe2 = executable('main2', 'main.c') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For completeness one of these two should have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not really what I'm testing here, I'm testing that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it is relevant for this. Rebuilding needs to work even if the end user has tagged a test executable as |
||
|
||
test('runner-with-exedep', runner, args: exe1) | ||
test('runner-without-dep', runner, args: exe2.full_path()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys, subprocess | ||
|
||
subprocess.run(sys.argv[1:], check=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I think this line could go after the
if not tests: return 0