Generated sys tests: Better command error handling #1499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The generated tests for
sys
crates sometimes callCommand::output
. It is used to find CFLAGS arguments for tested packages and run the executables created fromconstant.c
andlayout.c
tests.Command::output
, by default, capturesstdout
andstderr
. This means that, by default, no feedback for why the tests fail will be printed. The only information shown to the end-user is the command that was ran.You could copy/paste and run yourself the command printed in the error message, but it might not be evident as a "next step" for users.
This is unlike the compilation command, which uses
cmd.spawn()?.wait()?
. We can see compilation error messages, but not pkg-config error messages.To solve this, we:
stderr
from the parent descriptor. This will print the command's error message in the terminal.stdout
to the error message returned bypkg_config_cflags
andget_c_output
.Now. Errors generated by the spawned process are visible to the end user, which makes test errors more actionables.
The output is included for exhaustiveness. It may not be useful, but it makes sense to give to the user all the information necessary.