summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/install.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /src/tools/cargo/tests/testsuite/install.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/install.rs')
-rw-r--r--src/tools/cargo/tests/testsuite/install.rs121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/tools/cargo/tests/testsuite/install.rs b/src/tools/cargo/tests/testsuite/install.rs
index dd9844f17..9b881dfdc 100644
--- a/src/tools/cargo/tests/testsuite/install.rs
+++ b/src/tools/cargo/tests/testsuite/install.rs
@@ -1416,6 +1416,46 @@ fn path_install_workspace_root_despite_default_members() {
}
#[cargo_test]
+fn git_install_workspace_root_despite_default_members() {
+ let p = git::repo(&paths::root().join("foo"))
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "ws-root"
+ version = "0.1.0"
+ authors = []
+
+ [workspace]
+ members = ["ws-member"]
+ default-members = ["ws-member"]
+ "#,
+ )
+ .file("src/main.rs", "fn main() {}")
+ .file(
+ "ws-member/Cargo.toml",
+ r#"
+ [package]
+ name = "ws-member"
+ version = "0.1.0"
+ authors = []
+ "#,
+ )
+ .file("ws-member/src/main.rs", "fn main() {}")
+ .build();
+
+ cargo_process("install --git")
+ .arg(p.url().to_string())
+ .arg("ws-root")
+ .with_stderr_contains(
+ "[INSTALLED] package `ws-root v0.1.0 ([..])` (executable `ws-root[EXE]`)",
+ )
+ // Particularly avoid "Installed package `ws-root v0.1.0 ([..]])` (executable `ws-member`)":
+ .with_stderr_does_not_contain("ws-member")
+ .run();
+}
+
+#[cargo_test]
fn dev_dependencies_no_check() {
Package::new("foo", "1.0.0").publish();
let p = project()
@@ -2287,3 +2327,84 @@ fn sparse_install() {
"#,
);
}
+
+#[cargo_test]
+fn self_referential() {
+ // Some packages build-dep on prior versions of themselves.
+ Package::new("foo", "0.0.1")
+ .file("src/lib.rs", "fn hello() {}")
+ .file("src/main.rs", "fn main() {}")
+ .file("build.rs", "fn main() {}")
+ .publish();
+ Package::new("foo", "0.0.2")
+ .file("src/lib.rs", "fn hello() {}")
+ .file("src/main.rs", "fn main() {}")
+ .file("build.rs", "fn main() {}")
+ .build_dep("foo", "0.0.1")
+ .publish();
+
+ cargo_process("install foo")
+ .with_stderr(
+ "\
+[UPDATING] `[..]` index
+[DOWNLOADING] crates ...
+[DOWNLOADED] foo v0.0.2 (registry [..])
+[INSTALLING] foo v0.0.2
+[DOWNLOADING] crates ...
+[DOWNLOADED] foo v0.0.1 (registry [..])
+[COMPILING] foo v0.0.1
+[COMPILING] foo v0.0.2
+[FINISHED] release [optimized] target(s) in [..]
+[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
+[INSTALLED] package `foo v0.0.2` (executable `foo[EXE]`)
+[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
+",
+ )
+ .run();
+ assert_has_installed_exe(cargo_home(), "foo");
+}
+
+#[cargo_test]
+fn ambiguous_registry_vs_local_package() {
+ // Correctly install 'foo' from a local package, even if that package also
+ // depends on a registry dependency named 'foo'.
+ Package::new("foo", "0.0.1")
+ .file("src/lib.rs", "fn hello() {}")
+ .publish();
+
+ let p = project()
+ .file("src/main.rs", "fn main() {}")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ edition = "2021"
+
+ [dependencies]
+ foo = "0.0.1"
+ "#,
+ )
+ .build();
+
+ cargo_process("install --path")
+ .arg(p.root())
+ .with_stderr(
+ "\
+[INSTALLING] foo v0.1.0 ([..])
+[UPDATING] `[..]` index
+[DOWNLOADING] crates ...
+[DOWNLOADED] foo v0.0.1 (registry [..])
+[COMPILING] foo v0.0.1
+[COMPILING] foo v0.1.0 ([..])
+[FINISHED] release [optimized] target(s) in [..]
+[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
+[INSTALLED] package `foo v0.1.0 ([..])` (executable `foo[EXE]`)
+[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
+",
+ )
+ .run();
+ assert_has_installed_exe(cargo_home(), "foo");
+}