Fix #180: Handle workspaces more similar to cargo build/run/test
#182
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.
About
This PR fixes the reproducible issues mentioned in #180. Namely this is the different behavior between standard cargo commands and
cargo flamegraph
when using workspaces. The default cargo commands by default only take into account crates in the working directory whilecargo flamegraph
was working on the entire working space.The PR tries to amend that by changing
cargo flamegraph
behavior in the following ways:cargo flamegraph
chooses a target only from the current working directory unless--package
or--manifest-path
are used (instead of the entire workspace).cargo flamegraph
suggests targets only from the current working directory unless--package
or--manifest-path
are used (instead of the entire workspace).I tested the new version with several different dummy crates and workspaces as well as ripgrep. It seems to work fine and just like the standard cargo commands.
Breaking changes (Not sure if this is relevant for anyone though.)
As described above,
cargo flamegraph
no longer works on an entire workspace but only on the crate in the current working directory. This means that callingcargo flamegraph
in a crate within a workspace tries to execute the binary within this crate instead of the workspace binary.Example: calling
cargo flamegraph
inripgrep/crates/printer
(a library crate) now errors because it cannot find a binary instead of executingrg
(the workspace executable).Relevant issues