Skip to content

Commit

Permalink
Do not list dependency packages by MetadataCommand
Browse files Browse the repository at this point in the history
When following `cargo-fuzz` tutorial at
https://rust-fuzz.github.io/book/cargo-fuzz/tutorial.html,
after executing `cargo fuzz init`, `fuzz/Cargo.toml`
contains entry `[dependencies.matches]` instead of
`[dependencies.url]`. This is caused by `MetadataCommand`
listing dependency packages in addition to main packages
which is not desired.

This does work as expected if result of `MetadataCommand`
contains the first package as the non-dep package but that does
not seem to work all the time.
  • Loading branch information
kdarkhan committed Jan 8, 2024
1 parent 2e134b2 commit b02b2b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,11 +938,11 @@ pub struct Manifest {

impl Manifest {
pub fn parse() -> Result<Self> {
let metatdata = MetadataCommand::new().exec()?;
let package = metatdata.packages.first().with_context(|| {
let metadata = MetadataCommand::new().no_deps().exec()?;
let package = metadata.packages.first().with_context(|| {
anyhow!(
"Expected to find at least one package in {}",
metatdata.target_directory
metadata.target_directory
)
})?;
let crate_name = package.name.clone();
Expand Down

0 comments on commit b02b2b8

Please sign in to comment.