-
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
Added warning if check
kwarg of run_command
is not given.
#9304
Added warning if check
kwarg of run_command
is not given.
#9304
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9304 +/- ##
==========================================
- Coverage 67.29% 64.15% -3.14%
==========================================
Files 394 198 -196
Lines 85344 42662 -42682
Branches 17465 8729 -8736
==========================================
- Hits 57432 27371 -30061
+ Misses 23231 12994 -10237
+ Partials 4681 2297 -2384
Continue to review full report at Codecov.
|
@@ -9,7 +9,7 @@ foo = false | |||
|
|||
executable(target_name, target_src, build_by_default : foo) | |||
|
|||
r = run_command(find_program('c_compiler.py')) | |||
r = run_command(find_program('c_compiler.py'), check: false) | |||
if r.returncode() != 0 | |||
error('FAILED') |
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.
This one should should probably be check: true, lol
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.
Make sure we still have at least one place where we test with check: false
and a command that actually fails.
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.
33 run program
does that several times. assert(ret.returncode() == 0, 'failed to run python3: ' + ret.stderr())
If you're looking for one that is expected to error out and raises a testsuite failure if ret.returncode() == 0
, this doesn't do that either.
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.
If you run rg -F "check: false" test\ cases/
, you'll find this pattern at a couple of places:
r = run_command(..., check: false)
if r.returncode() != 0
error('some error')
endif
(sometimes with an if clause, sometimes with an assert). This can be removed if we set check
to true
, but this would change the error message.
In some places (like error('FAILED')
), this error message isn't better than the default, but in some other places it is.
I think you should decide which places should keep their custom error messages and which places can use the default error message.
@@ -15,7 +15,7 @@ if not is_windows and build_machine.system() != 'cygwin' | |||
# * Windows user permissions to create symlinks, and/or Windows in Developer mode | |||
# so at this time the symlink test is skipped for Windows. | |||
symlink = meson.current_build_dir() / 'a_symlink' | |||
run_command('ln', '-s', meson.current_source_dir() / 'meson.build', symlink) | |||
run_command('ln', '-s', meson.current_source_dir() / 'meson.build', symlink, 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.
This is a great error right here!
The test runner configures this test case correctly, and it succeeds in generating, running, and in theory passing. But the test runner also checks that the backend will correctly force regeneration for build/test, by updating the utime of meson.build.
On this second run, the ln
program fails because
--- stderr ---
/usr/bin/ln: failed to create symbolic link '/tmp/b d19af95f3b/a_symlink': File exists
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.
(after your latest push)
Note that the additional -f
flag to ln would make it overwrite the existing symlink rather than erroring.
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.
Done
Meson PRs cannot include merge commits. Please rebase instead. Also the "simple bug fix" commit should be squashed into the commit which it is fixing. |
e78ef72
to
74cd845
Compare
I fought with git for a while and ended up saving a code-diff elsewhere, deleting my local repo, and force-pushing a commit created from the code-diff. Relevant xkcd: https://xkcd.com/1597/ |
That sounds complicated... I'd just Anyway, changes seem okay, let's see what CI thinks. |
Then I would have to create a new PR, because this PR wants to merge check_false_warning and not newbranch |
Oh! Almost forgot... sorry... This should get a release notes snippet in |
Nah, you can push branches like this:
Or actually, it's a good point that you could/should also set |
74cd845
to
bb0ee05
Compare
Done |
meson/test cases/unit/24 compiler run_command/meson.build Lines 4 to 10 in 437745b
Fails on Windows with:
This case should be |
bb0ee05
to
8fb78b1
Compare
Done |
We do care about this, please don't remove it. :) |
8fb78b1
to
d76b5e1
Compare
Oops, my fault, fixed. |
Alright, thanks. This seems good to me, so it should be merged as soon as the release candidate freeze ends. |
Thanks! |
An update to meson 0.61.1 meant that it started showing warnings due to the fact that the default for run_command's 'check' parameter is going to change. It unveiled the fact that we were even missing that parameter in some calls where we expected different outcome. To make sure the behaviour does not change specify the parameter explicitly. In places where we check for the return code the parameter should be 'false' so that meson does not fail. In all other cases the parameter should be set to 'true' to make sure possible failure also stops meson. The warning in meson was added in mesonbuild/meson#9304 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
See #9300