From 308582eeea960a8d1570b2bf73dc12925dae8786 Mon Sep 17 00:00:00 2001 From: rami3l Date: Sun, 29 Dec 2024 10:37:48 +0800 Subject: [PATCH 1/3] feat(test): accept more than one args in `for_host*!()` --- src/test.rs | 4 ++-- tests/suite/cli_rustup.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test.rs b/src/test.rs index ade2c2e901..afc69dbc66 100644 --- a/src/test.rs +++ b/src/test.rs @@ -178,8 +178,8 @@ pub fn this_host_triple() -> String { // Format a string with this host triple. #[macro_export] macro_rules! for_host { - ($s: expr) => { - &format!($s, $crate::test::this_host_triple()) + ($s:tt $($arg:tt)*) => { + &format!($s, $crate::test::this_host_triple() $($arg)*) }; } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index bae23ad5b7..0620d75cc9 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -15,8 +15,8 @@ use rustup::test::{ use rustup::utils::raw; macro_rules! for_host_and_home { - ($config:expr, $s: expr) => { - &format!($s, this_host_triple(), $config.rustupdir) + ($config:expr, $s:tt $($arg:tt)*) => { + &format!($s, this_host_triple(), $config.rustupdir $($arg)*) }; } From 4b304253763605ccdd0a640c60d0914de386defd Mon Sep 17 00:00:00 2001 From: rami3l Date: Sun, 29 Dec 2024 10:21:19 +0800 Subject: [PATCH 2/3] feat(cli): show the toolchain path with `rustup show active-toolchain --verbose` --- src/cli/rustup_mode.rs | 5 +++-- tests/suite/cli_rustup.rs | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 2a4152ccd0..b7e450cf1f 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1092,8 +1092,9 @@ fn show_active_toolchain(cfg: &Cfg<'_>, verbose: bool) -> Result Date: Sun, 29 Dec 2024 11:04:30 +0800 Subject: [PATCH 3/3] fix(cli): align `rustup show`'s `--verbose` behavior with `rustup show active-toolchain` --- src/cli/rustup_mode.rs | 5 ++++- tests/suite/cli_rustup.rs | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index b7e450cf1f..4ccda4678a 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1045,8 +1045,11 @@ fn show(cfg: &Cfg<'_>, verbose: bool) -> Result { &active_reason, )?; writeln!(t.lock(), "name: {}", active_toolchain.name())?; - writeln!(t.lock(), "compiler: {}", active_toolchain.rustc_version())?; writeln!(t.lock(), "active because: {}", active_reason)?; + if verbose { + writeln!(t.lock(), "compiler: {}", active_toolchain.rustc_version())?; + writeln!(t.lock(), "path: {}", active_toolchain.path().display())?; + } // show installed targets for the active toolchain writeln!(t.lock(), "installed targets:")?; diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 33a05efe70..951e7fd66e 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -661,7 +661,6 @@ nightly-{0} (active, default) active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (hash-nightly-2) active because: it's the default toolchain installed targets: {0} @@ -735,7 +734,6 @@ nightly-{0} (active, default) active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (hash-nightly-2) active because: it's the default toolchain installed targets: {0} @@ -774,7 +772,6 @@ nightly-{0} (active, default) active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (xxxx-nightly-2) active because: it's the default toolchain installed targets: {1} @@ -831,7 +828,6 @@ nightly-{0} (active, default) active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (xxxx-nightly-2) active because: it's the default toolchain installed targets: {1} @@ -1139,7 +1135,6 @@ nightly-{0} (active, default) active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (hash-nightly-2) active because: overridden by environment variable RUSTUP_TOOLCHAIN installed targets: {0} @@ -1227,11 +1222,17 @@ nightly-2015-01-01-{0} active toolchain ---------------- name: nightly-{0} -compiler: 1.3.0 (hash-nightly-2) active because: it's the default toolchain +compiler: 1.3.0 (hash-nightly-2) +path: {2} installed targets: {0} -" +", + config + .rustupdir + .join("toolchains") + .join(for_host!("nightly-{0}")) + .display() ), r"", )