Skip to content

Commit 03a2a29

Browse files
committed
add test for cargo script workspace handling
1 parent bfe4128 commit 03a2a29

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/testsuite/script.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,3 +1886,56 @@ CARGO_MANIFEST_PATH: [ROOT]/foo/script.rs
18861886
"#]])
18871887
.run();
18881888
}
1889+
1890+
#[cargo_test]
1891+
fn ignore_surrounding_workspace() {
1892+
let p = cargo_test_support::project()
1893+
.file(
1894+
std::path::Path::new(".cargo").join("config.toml"),
1895+
r#"
1896+
[registries.test-reg]
1897+
index = "https://github.com/rust-lang/crates.io-index"
1898+
"#,
1899+
)
1900+
.file(
1901+
std::path::Path::new("inner").join("Cargo.toml"),
1902+
r#"
1903+
[package]
1904+
name = "inner"
1905+
version = "0.1.0"
1906+
1907+
[dependencies]
1908+
serde = { version = "1.0", registry = "test-reg" }
1909+
"#,
1910+
)
1911+
.file(std::path::Path::new("inner").join("src").join("lib.rs"), "")
1912+
.file(std::path::Path::new("script").join("echo.rs"), ECHO_SCRIPT)
1913+
.file(
1914+
"Cargo.toml",
1915+
r#"
1916+
[workspace]
1917+
members = [
1918+
"inner",
1919+
]
1920+
"#,
1921+
)
1922+
.build();
1923+
1924+
p.cargo("-Zscript -v script/echo.rs")
1925+
.masquerade_as_nightly_cargo(&["script"])
1926+
.with_stdout_data(str![[r#""#]])
1927+
.with_stderr_data(str![[r#"
1928+
[WARNING] `package.edition` is unspecified, defaulting to `2024`
1929+
[ERROR] failed to load manifest for workspace member `[ROOT]/foo/inner`
1930+
referenced by workspace at `[ROOT]/foo/Cargo.toml`
1931+
1932+
Caused by:
1933+
failed to parse manifest at `[ROOT]/foo/inner/Cargo.toml`
1934+
1935+
Caused by:
1936+
registry index was not found in any configuration: `test-reg`
1937+
1938+
"#]])
1939+
.with_status(101)
1940+
.run();
1941+
}

0 commit comments

Comments
 (0)