Skip to content

Commit daf3b81

Browse files
committed
test: add a test case for the relative location
1 parent f8e1c9f commit daf3b81

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/testsuite/install.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,43 @@ fn install_location_precedence() {
500500
assert_has_installed_exe(&t4, "foo");
501501
}
502502

503+
#[cargo_test]
504+
fn relative_install_location() {
505+
let p = project().file("src/main.rs", "fn main() {}").build();
506+
507+
let root = paths::root();
508+
let root_t1 = root.join("t1");
509+
let p_path = p.root().to_path_buf();
510+
let project_t1 = p_path.join("t1");
511+
512+
fs::create_dir(root.join(".cargo")).unwrap();
513+
fs::write(
514+
root.join(".cargo/config.toml"),
515+
r#"
516+
[install]
517+
root = "t1"
518+
"#,
519+
)
520+
.unwrap();
521+
522+
let mut cmd = cargo_process("install --path .");
523+
cmd.cwd(p.root());
524+
cmd.with_stderr_data(str![[r#"
525+
[INSTALLING] foo v0.0.1 ([ROOT]/foo)
526+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
527+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
528+
[INSTALLING] t1/bin/foo
529+
[INSTALLED] package `foo v0.0.1 ([ROOT]/foo)` (executable `foo`)
530+
[WARNING] be sure to add `t1/bin` to your PATH to be able to run the installed binaries
531+
532+
"#]])
533+
.run();
534+
535+
// NOTE: the install location is relative to the CWD, not the config file
536+
assert_has_not_installed_exe(&root_t1, "foo");
537+
assert_has_installed_exe(&project_t1, "foo");
538+
}
539+
503540
#[cargo_test]
504541
fn install_path() {
505542
let p = project().file("src/main.rs", "fn main() {}").build();

0 commit comments

Comments
 (0)