Skip to content

Commit

Permalink
Add features to the default Cargo.toml file
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <[email protected]>
  • Loading branch information
Rustin170506 committed Nov 19, 2023
1 parent 9765a44 commit 32505a7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
24 changes: 24 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 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.

3 changes: 2 additions & 1 deletion tests/testsuite/cargo_remove/update_lock_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ fn case() {
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
let ch = cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();
println!("ch: {:?}", ch);

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
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 32505a7

Please sign in to comment.