Skip to content

Commit

Permalink
Auto merge of #12997 - hi-rustin:rustin-patch-cargo-test-support, r=e…
Browse files Browse the repository at this point in the history
…page

cargo-test-support: Add features to the default Cargo.toml file
  • Loading branch information
bors committed Nov 22, 2023
2 parents eed300d + 504c4b2 commit 65d0eb5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
27 changes: 27 additions & 0 deletions crates/cargo-test-support/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,30 @@ impl Package {
manifest.push_str(&format!("rust-version = \"{}\"", version));
}

if !self.features.is_empty() {
let features: Vec<String> = self
.features
.iter()
.map(|(feature, features)| {
if features.is_empty() {
format!("{} = []", feature)
} else {
format!(
"{} = [{}]",
feature,
features
.iter()
.map(|s| format!("\"{}\"", s))
.collect::<Vec<_>>()
.join(", ")
)
}
})
.collect();

manifest.push_str(&format!("\n[features]\n{}", features.join("\n")));
}

for dep in self.deps.iter() {
let target = match dep.target {
None => String::new(),
Expand All @@ -1540,6 +1564,9 @@ impl Package {
"#,
target, kind, dep.name, dep.vers
));
if dep.optional {
manifest.push_str("optional = true\n");
}
if let Some(artifact) = &dep.artifact {
manifest.push_str(&format!("artifact = \"{}\"\n", artifact));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock

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

4 changes: 2 additions & 2 deletions tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock

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

0 comments on commit 65d0eb5

Please sign in to comment.