Test: install with path outside current workspace

Make up this test case to reflect the current incorrect behavior.
This commit is contained in:
Weihang Lo 2022-01-27 17:50:43 +08:00
parent 1c034752de
commit d323ad672c
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -7,7 +7,7 @@ use cargo_test_support::cross_compile;
use cargo_test_support::git;
use cargo_test_support::registry::{self, registry_path, registry_url, Package};
use cargo_test_support::{
basic_manifest, cargo_process, no_such_file_err_msg, project, symlink_supported, t,
basic_manifest, cargo_process, no_such_file_err_msg, project, project_in, symlink_supported, t,
};
use cargo_test_support::install::{
@ -493,6 +493,57 @@ but found cargo.toml please try to rename it to Cargo.toml. --path must point to
.run();
}
#[cargo_test]
fn install_relative_path_outside_current_ws() {
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 = []
edition = "2021"
[dependencies]
foo = "1"
"#,
)
.file("baz/src/lib.rs", "")
.build();
let _bin_project = project_in("bar")
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("install --path ../bar/foo")
.with_status(101)
.with_stderr(
"\
[ERROR] current package believes it's in a workspace when it's not:
current: [CWD]/../bar/foo/Cargo.toml
workspace: [CWD]/Cargo.toml
this may be fixable by adding `../bar/foo` to the `workspace.members` [..]
Alternatively, [..]
",
)
.run();
}
#[cargo_test]
fn multiple_crates_error() {
let p = git::repo(&paths::root().join("foo"))