diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 875a7a636..80cd1f314 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1587,3 +1587,57 @@ fn install_yanked_cargo_package() { ) .run(); } + +#[cargo_test] +fn install_cargo_package_in_a_patched_workspace() { + pkg("foo", "0.1.0"); + pkg("fizz", "1.0.0"); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + + [workspace] + members = ["baz"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file( + "baz/Cargo.toml", + r#" + [package] + name = "baz" + version = "0.1.0" + authors = [] + + [dependencies] + fizz = "1" + + [patch.crates-io] + fizz = { version = "=1.0.0" } + "#, + ) + .file("baz/src/lib.rs", "") + .build(); + + let stderr = "\ +[WARNING] patch for the non root package will be ignored, specify patch at the workspace root: +package: [..]/foo/baz/Cargo.toml +workspace: [..]/foo/Cargo.toml +"; + p.cargo("check") + .with_stderr_contains(&stderr) + .run(); + + // A crate installation must not emit any message from a workspace under + // current working directory. + // See https://github.com/rust-lang/cargo/issues/8619 + p.cargo("install foo") + .with_stderr_does_not_contain(&stderr) + .run(); +}