Skip to content

Commit 4fc7444

Browse files
committed
test: add the path has been set case
1 parent e13f98f commit 4fc7444

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/install.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,48 @@ fn relative_install_location_with_trailing_slash() {
573573
assert_has_not_installed_exe(&project_t1, "foo");
574574
}
575575

576+
#[cargo_test]
577+
fn relative_install_location_with_path_set() {
578+
// Test that when the absolute install path is in PATH, no warning is shown
579+
let p = project().file("src/main.rs", "fn main() {}").build();
580+
581+
let root = paths::root();
582+
let p_path = p.root().to_path_buf();
583+
let project_t1 = p_path.join("t1");
584+
585+
fs::create_dir(root.join(".cargo")).unwrap();
586+
fs::write(
587+
root.join(".cargo/config.toml"),
588+
r#"
589+
[install]
590+
root = "t1"
591+
"#,
592+
)
593+
.unwrap();
594+
595+
// Add the absolute path to PATH environment variable
596+
let install_bin_path = project_t1.join("bin");
597+
let mut path = path();
598+
path.push(install_bin_path);
599+
let new_path = env::join_paths(path).unwrap();
600+
601+
let mut cmd = cargo_process("install --path .");
602+
cmd.cwd(p.root());
603+
cmd.env("PATH", new_path);
604+
cmd.with_stderr_data(str![[r#"
605+
[INSTALLING] foo v0.0.1 ([ROOT]/foo)
606+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
607+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
608+
[INSTALLING] t1/bin/foo[EXE]
609+
[INSTALLED] package `foo v0.0.1 ([ROOT]/foo)` (executable `foo[EXE]`)
610+
[WARNING] be sure to add `t1/bin` to your PATH to be able to run the installed binaries
611+
612+
"#]])
613+
.run();
614+
615+
assert_has_installed_exe(&project_t1, "foo");
616+
}
617+
576618
#[cargo_test]
577619
fn install_path() {
578620
let p = project().file("src/main.rs", "fn main() {}").build();

0 commit comments

Comments
 (0)