Skip to content

Commit bf3885e

Browse files
committed
Add tests for cargo vendor error cases resolving
1 parent 21f4080 commit bf3885e

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

tests/testsuite/vendor.rs

+86
Original file line numberDiff line numberDiff line change
@@ -1981,3 +1981,89 @@ directory = "new-vendor-dir"
19811981
"#]])
19821982
.run();
19831983
}
1984+
1985+
#[cargo_test]
1986+
fn error_loading_which_lock() {
1987+
// Tests an error message to make sure it is clear which
1988+
// manifest/workspace caused the problem. In this particular case, it was
1989+
// because the 2024 edition wants to know which rust version is in use.
1990+
let p = project()
1991+
.file(
1992+
"Cargo.toml",
1993+
r#"
1994+
[package]
1995+
name = "a"
1996+
version = "0.1.0"
1997+
"#,
1998+
)
1999+
.file("src/lib.rs", "")
2000+
.file(
2001+
"b/Cargo.toml",
2002+
r#"
2003+
[package]
2004+
name = "b"
2005+
version = "0.1.0"
2006+
edition = "2024"
2007+
"#,
2008+
)
2009+
.file("b/src/lib.rs", "")
2010+
.build();
2011+
2012+
p.cargo("vendor --respect-source-config -s b/Cargo.toml")
2013+
.env("RUSTC", "does-not-exist")
2014+
.with_status(101)
2015+
.with_stderr_data(str![[r#"
2016+
[ERROR] failed to sync
2017+
2018+
Caused by:
2019+
failed to load pkg lockfile
2020+
2021+
Caused by:
2022+
could not execute process `does-not-exist -vV` (never executed)
2023+
2024+
Caused by:
2025+
[NOT_FOUND]
2026+
2027+
"#]])
2028+
.run();
2029+
}
2030+
2031+
#[cargo_test]
2032+
fn error_downloading() {
2033+
// Tests the error message when downloading packages.
2034+
let p = project()
2035+
.file(
2036+
"Cargo.toml",
2037+
r#"
2038+
[package]
2039+
name = "foo"
2040+
version = "0.1.0"
2041+
2042+
[dependencies]
2043+
bar = "1.0"
2044+
"#,
2045+
)
2046+
.file("src/lib.rs", "")
2047+
.build();
2048+
2049+
Package::new("bar", "1.0.0").publish();
2050+
p.cargo("generate-lockfile").run();
2051+
std::fs::remove_file(cargo_test_support::paths::root().join("dl/bar/1.0.0/download")).unwrap();
2052+
p.cargo("vendor --respect-source-config")
2053+
.with_status(101)
2054+
.with_stderr_data(str![[r#"
2055+
[DOWNLOADING] crates ...
2056+
[ERROR] failed to sync
2057+
2058+
Caused by:
2059+
failed to download packages
2060+
2061+
Caused by:
2062+
failed to download from `[ROOTURL]/dl/bar/1.0.0/download`
2063+
2064+
Caused by:
2065+
[37] Could[..]t read a file:// file (Couldn't open file [ROOT]/dl/bar/1.0.0/download)
2066+
2067+
"#]])
2068+
.run();
2069+
}

0 commit comments

Comments
 (0)