Skip to content

Commit 235ba90

Browse files
committed
fix(command-vendor): reproduce the panic of cp_sources
1 parent 28163c0 commit 235ba90

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/testsuite/vendor.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,3 +2086,43 @@ Caused by:
20862086
"#]])
20872087
.run();
20882088
}
2089+
2090+
#[cargo_test(ignore_windows = "annoying to create a repro on Windows; see rust-lang/cargo#16214")]
2091+
fn vendor_rename_fallback() {
2092+
let p = project()
2093+
.file(
2094+
"Cargo.toml",
2095+
r#"
2096+
[package]
2097+
name = "foo"
2098+
version = "0.1.0"
2099+
2100+
[dependencies]
2101+
log = "0.3.5"
2102+
"#,
2103+
)
2104+
.file("src/lib.rs", "")
2105+
.build();
2106+
2107+
Package::new("log", "0.3.5").publish();
2108+
2109+
// Create vendor/log as a file to force rename failure
2110+
let vendor_dir = p.root().join("vendor");
2111+
fs::create_dir_all(&vendor_dir).unwrap();
2112+
fs::write(vendor_dir.join("log"), "blocking file").unwrap();
2113+
2114+
p.cargo("vendor --respect-source-config --no-delete")
2115+
.env("CARGO_LOG", "cargo::ops::vendor=warn")
2116+
.with_status(101)
2117+
.with_stderr_data(str![[r#"
2118+
...
2119+
[..]failed to `mv "[..]vendor[..].vendor-staging[..]log-0.3.5" "[..]vendor[..]log"`: [..]
2120+
...
2121+
[..]StripPrefixError[..]
2122+
...
2123+
"#]])
2124+
.run();
2125+
2126+
// The cp_sources fallback always didn't work because of the StripPrefixError
2127+
assert!(!p.root().join("vendor/log/Cargo.toml").exists());
2128+
}

0 commit comments

Comments
 (0)