Skip to content

Commit 48f147c

Browse files
committed
test: show problematic behavior that delete non-cached sources
Sources like directory sources (which usually are vendored source) likely contains real sources not cached sources. Cargo shouldn't delete them.
1 parent abe461c commit 48f147c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/testsuite/vendor.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,3 +1939,44 @@ fn vendor_crate_with_ws_inherit() {
19391939
"#]])
19401940
.run();
19411941
}
1942+
1943+
#[cargo_test]
1944+
fn dont_delete_non_registry_sources_with_respect_source_config() {
1945+
let p = project()
1946+
.file(
1947+
"Cargo.toml",
1948+
r#"
1949+
[package]
1950+
name = "foo"
1951+
version = "0.1.0"
1952+
1953+
[dependencies]
1954+
log = "0.3.5"
1955+
"#,
1956+
)
1957+
.file("src/lib.rs", "")
1958+
.build();
1959+
1960+
Package::new("log", "0.3.5").publish();
1961+
1962+
p.cargo("vendor --respect-source-config").run();
1963+
let lock = p.read_file("vendor/log/Cargo.toml");
1964+
assert!(lock.contains("version = \"0.3.5\""));
1965+
1966+
add_crates_io_vendor_config(&p);
1967+
p.cargo("vendor --respect-source-config new-vendor-dir")
1968+
.with_status(101)
1969+
.with_stderr_data(str![[r#"
1970+
[ERROR] failed to sync
1971+
1972+
Caused by:
1973+
failed to load pkg lockfile
1974+
1975+
Caused by:
1976+
no matching package named `log` found
1977+
location searched: directory source `[ROOT]/foo/vendor` (which is replacing registry `crates-io`)
1978+
required by package `foo v0.1.0 ([ROOT]/foo)`
1979+
1980+
"#]])
1981+
.run();
1982+
}

0 commit comments

Comments
 (0)