Skip to content

Commit

Permalink
Auto merge of #10348 - epage:vendor, r=alexcrichton
Browse files Browse the repository at this point in the history
fix(vendor): Use tables for sample config

Fixes #10345
  • Loading branch information
bors committed Jan 31, 2022
2 parents 74ec39f + fb9d11b commit a59d202
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cargo/ops/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> {
config,
"To use vendored sources, add this to your .cargo/config.toml for this project:\n\n"
);
crate::drop_print!(config, "{}", &toml::to_string(&vendor_config).unwrap());
crate::drop_print!(
config,
"{}",
&toml::to_string_pretty(&vendor_config).unwrap()
);
}
}

Expand Down
32 changes: 32 additions & 0 deletions tests/testsuite/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@ fn vendor_simple() {
p.cargo("build").run();
}

#[cargo_test]
fn vendor_sample_config() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
log = "0.3.5"
"#,
)
.file("src/lib.rs", "")
.build();

Package::new("log", "0.3.5").publish();

p.cargo("vendor --respect-source-config")
.with_stdout(
r#"
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
"#,
)
.run();
}

fn add_vendor_config(p: &Project) {
p.change_file(
".cargo/config",
Expand Down

0 comments on commit a59d202

Please sign in to comment.