diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 1aca9d982f9..a58f5c23c49 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -713,6 +713,45 @@ info: toolchain 'test' uninstalled }); } +// issue #3737 +#[test] +#[cfg(any(unix, windows))] +fn toolchain_symlink() { + use rustup::utils::raw::symlink_dir; + use std::fs; + + clitools::test(Scenario::SimpleV2, &|config| { + config.expect_ok(&["rustup", "toolchain", "install", "nightly"]); + + let cwd = config.current_dir(); + let test_rustupdir = cwd.join("rustup-test"); + let test_toolchains = test_rustupdir.join("toolchains"); + fs::create_dir_all(&test_toolchains).unwrap(); + symlink_dir(&config.rustupdir.join("toolchains"), &test_toolchains).unwrap(); + + let home_override = &[("RUSTUP_HOME", test_rustupdir.to_str().unwrap())]; + + let out = config.run("rustup", ["toolchain", "list"], home_override); + assert!(out.ok); + assert!(out.stdout.contains("nightly")); + + let out = config.run("rustc", ["+nightly", "--version"], home_override); + assert!(out.ok); + assert!(out.stdout.contains("hash-nightly-2")); + + let out = config.run( + "rustup", + ["toolchain", "uninstall", "nightly"], + home_override, + ); + assert!(out.ok); + config.expect_stdout_ok( + &["rustup", "toolchain", "list"], + "no installed toolchains\n", + ); + }); +} + // issue #1297 #[test] fn update_unavailable_rustc() {