diff --git a/src/project.rs b/src/project.rs index 27d08da..4150673 100644 --- a/src/project.rs +++ b/src/project.rs @@ -938,11 +938,11 @@ pub struct Manifest { impl Manifest { pub fn parse() -> Result { - 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(); diff --git a/tests/tests/main.rs b/tests/tests/main.rs index c3f2c7f..d779369 100644 --- a/tests/tests/main.rs +++ b/tests/tests/main.rs @@ -98,6 +98,40 @@ fn init_finds_parent_project() { assert!(project.fuzz_target_path("fuzz_target_1").is_file()); } +#[test] +fn init_defines_correct_dependency() { + let project_name = "project_with_some_dep"; + let project = project(project_name) + .file( + "Cargo.toml", + &format!( + r#" + [workspace] + [package] + name = "{name}" + version = "1.0.0" + + [dependencies] + matches = "0.1.10" + "#, + name = project_name + ), + ) + .build(); + project + .cargo_fuzz() + .current_dir(project.root().join("src")) + .arg("init") + .assert() + .success(); + assert!(project.fuzz_dir().is_dir()); + assert!(project.fuzz_cargo_toml().is_file()); + let cargo_toml = fs::read_to_string(project.fuzz_cargo_toml()).unwrap(); + let expected_dependency_attrs = + &format!("[dependencies.{name}]\npath = \"..\"", name = project_name); + assert!(cargo_toml.contains(expected_dependency_attrs)); +} + #[test] fn add() { let project = project("add").with_fuzz().build();