Skip to content

Commit

Permalink
Add a test for enabled renamed optional deps
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Nov 15, 2023
1 parent 2960f3a commit ae50926
Show file tree
Hide file tree
Showing 5 changed files with 7,402 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crate_universe/src/metadata/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,4 +697,21 @@ mod test {
.expect("Iterating over known keys should never panic")
.any(|dep| { dep.target_name == "mio" }));
}

#[test]
fn renamed_optional_deps_enabled() {
let metadata = metadata::renamed_optional_deps_enabled();

let p256 = find_metadata_node("p256", &metadata);
let p256_depset = DependencySet::new_for_node(p256, &metadata);
assert_eq!(
p256_depset
.normal_deps
.get_iter(None)
.expect("Iterating over known keys should never panic")
.filter(|dep| { dep.target_name == "ecdsa" })
.count(),
1
);
}
}
8 changes: 8 additions & 0 deletions crate_universe/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ pub mod metadata {
.unwrap()
}

pub fn renamed_optional_deps_enabled() -> cargo_metadata::Metadata {
serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_data/metadata/crate_renamed_optional_deps_enabled/metadata.json"
)))
.unwrap()
}

pub fn common() -> cargo_metadata::Metadata {
serde_json::from_str(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "crate-with-optional-deps"
version = "0.1.0"
edition = "2021" # make sure resolver=2 is enabled for this test

# Required to satisfy cargo but no `lib.rs` is expected to
# exist within test data.
[lib]
path = "lib.rs"

[dependencies]
p256 = "=0.13.2"

Loading

0 comments on commit ae50926

Please sign in to comment.