Skip to content

Commit 2bf90ff

Browse files
committed
wrote 3 tests about invalid_package_name_path, invalid_package_in_subdirectory and invalid_manifest_in_path
made the tests pass by showing the current behaviour added generate-lockfile in the remaining two tests
1 parent 3b379fc commit 2bf90ff

File tree

1 file changed

+150
-2
lines changed

1 file changed

+150
-2
lines changed

tests/testsuite/path.rs

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,8 @@ fn invalid_base() {
10971097
.with_stderr_data(
10981098
"\
10991099
[ERROR] invalid character `^` in path base name: `^^not-valid^^`, the first character must be a Unicode XID start character (most letters or `_`)
1100-
1101-
1100+
1101+
11021102
--> Cargo.toml:10:23
11031103
|
11041104
10 | bar = { base = '^^not-valid^^', path = 'bar' }
@@ -1919,3 +1919,151 @@ foo v1.0.0 ([ROOT]/foo)
19191919
"#]])
19201920
.run();
19211921
}
1922+
1923+
#[cargo_test]
1924+
fn invalid_package_name_in_path() {
1925+
let p = project()
1926+
.file(
1927+
"Cargo.toml",
1928+
r#"
1929+
[package]
1930+
name = "foo"
1931+
version = "0.5.0"
1932+
edition = "2015"
1933+
authors = []
1934+
1935+
[workspace]
1936+
1937+
[dependencies]
1938+
definitely_not_bar = { path = "crates/bar" }
1939+
"#,
1940+
)
1941+
.file("src/lib.rs", "")
1942+
.file(
1943+
"crates/bar/Cargo.toml",
1944+
r#"
1945+
[package]
1946+
name = "bar"
1947+
version = "0.5.0"
1948+
edition = "2015"
1949+
authors = []
1950+
"#,
1951+
)
1952+
.file("crates/bar/src/lib.rs", "")
1953+
.build();
1954+
1955+
p.cargo("generate-lockfile")
1956+
.with_status(101)
1957+
.with_stderr_data(str![[r#"
1958+
[ERROR] no matching package named `definitely_not_bar` found
1959+
location searched: [ROOT]/foo/crates/bar
1960+
required by package `foo v0.5.0 ([ROOT]/foo)`
1961+
1962+
"#]])
1963+
.run();
1964+
}
1965+
1966+
#[cargo_test]
1967+
fn invalid_package_in_subdirectory() {
1968+
let p = project()
1969+
.file(
1970+
"Cargo.toml",
1971+
r#"
1972+
[package]
1973+
name = "foo"
1974+
version = "0.5.0"
1975+
edition = "2015"
1976+
authors = []
1977+
1978+
[workspace]
1979+
1980+
[dependencies]
1981+
definitely_not_bar = { path = "crates/bar" }
1982+
"#,
1983+
)
1984+
.file("src/lib.rs", "")
1985+
.file(
1986+
"crates/bar/definitely_not_bar/Cargo.toml",
1987+
r#"
1988+
[package]
1989+
name = "definitely_not_bar"
1990+
version = "0.5.0"
1991+
edition = "2015"
1992+
authors = []
1993+
"#,
1994+
)
1995+
.file("crates/bar/definitely_not_bar/src/lib.rs", "")
1996+
.build();
1997+
1998+
p.cargo("generate-lockfile")
1999+
.with_status(101)
2000+
.with_stderr_data(str![[r#"
2001+
[ERROR] failed to load manifest for dependency `definitely_not_bar`
2002+
2003+
Caused by:
2004+
failed to read `[ROOT]/foo/crates/bar/Cargo.toml`
2005+
2006+
Caused by:
2007+
[NOT_FOUND]
2008+
2009+
"#]])
2010+
.run();
2011+
}
2012+
2013+
#[cargo_test]
2014+
fn invalid_manifest_in_path() {
2015+
let p = project()
2016+
.file(
2017+
"Cargo.toml",
2018+
r#"
2019+
[package]
2020+
name = "foo"
2021+
version = "0.5.0"
2022+
edition = "2015"
2023+
authors = []
2024+
2025+
[workspace]
2026+
2027+
[dependencies]
2028+
definitely_not_bar = { path = "crates/bar" }
2029+
"#,
2030+
)
2031+
.file("src/lib.rs", "")
2032+
.file(
2033+
"crates/bar/alice/Cargo.toml",
2034+
r#"
2035+
[package]
2036+
name = "alice"
2037+
version = "0.5.0"
2038+
edition = "2015"
2039+
authors = []
2040+
"#,
2041+
)
2042+
.file("crates/bar/alice/src/lib.rs", "")
2043+
.file(
2044+
"crates/bar/bob/Cargo.toml",
2045+
r#"
2046+
[package]
2047+
name = "bob"
2048+
version = "0.5.0"
2049+
edition = "2015"
2050+
authors = []
2051+
"#,
2052+
)
2053+
.file("crates/bar/bob/src/lib.rs", "")
2054+
.build();
2055+
2056+
p.cargo("generate-lockfile")
2057+
.with_status(101)
2058+
.with_stderr_data(str![[r#"
2059+
[ERROR] failed to load manifest for dependency `definitely_not_bar`
2060+
2061+
Caused by:
2062+
failed to read `[ROOT]/foo/crates/bar/Cargo.toml`
2063+
2064+
Caused by:
2065+
[NOT_FOUND]
2066+
2067+
"#]])
2068+
.run();
2069+
}

0 commit comments

Comments
 (0)