cargo
cargo copied to clipboard
Add a `--dry-run` flag to the `install` command
What does this PR try to resolve?
This PR add the --dry-run flag to the cargo install command (see #11123).
I've tried to do the bare minimal for this flag to work without changing anything in the output.
In my opinion, the --dry-run flag should mimic as close as possible the behavior of the normal command to avoid missing potential issue in the normal execution. ~~Currently we're missing information about where the binary will be installed.~~
Unlike #13598 this PR:
- Include as much of the compilation process as possible without actually compiling
- use the information provided by
BuildContextinstead ofInstallablePackage::new - in the same way as
unit_graph, it add adry_runto theCompileOptionsand return aCompilation::newfrom the functioncompile_wswithout actually compiling. - keeps the output the same rather than adding status messages indicating which very broad actions would be performed
- ~~remove some warning not relevant in the case of a
--dry-run~~
Like #13598, the version check and crate downloads still occur.
How should we test and review this PR?
The first commit include a unit tests to ensure that no binary is actually installed after the dry run.
There is also a snapshot test that show the diff output of the --help flag.
Additional information
Tests and documentation done in #13598, may be cherry picked into this PR if needed.
r? @ehuss
rustbot has assigned @ehuss. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
r? epage If you don't mind, feel free to reassign if you are too busy.
Note: I tweaked the commits to make this easier to review.
Note: I tweaked the commits to make this easier to review.
Thanks, sorry if i made a mess with the commits :sweat_smile:
@bors r+
:pushpin: Commit b0e08fcd3278b727a4492832316c39efd5433d77 has been approved by weihanglo
It is now in the queue for this repository.
:hourglass: Testing commit b0e08fcd3278b727a4492832316c39efd5433d77 with merge d7bffc302ef83dd8a4bf06bd4fb7579e7988263e...
:sunny: Test successful - checks-actions Approved by: weihanglo Pushing d7bffc302ef83dd8a4bf06bd4fb7579e7988263e to master...