Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for enabled renamed optional deps
Browse files Browse the repository at this point in the history
nbdd0121 committed Nov 15, 2023
1 parent b5bfded commit 4b30a8b
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
@@ -722,4 +722,21 @@ mod test {
.expect("Iterating over known keys should never panic")
.any(|dep| dep.target_name == "serde"));
}

#[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
@@ -123,6 +123,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"),

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"

Large diffs are not rendered by default.

0 comments on commit 4b30a8b

Please sign in to comment.