From 4f4e983422a1efc36edfe3654b4bbe9a1af4210b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 28 Oct 2025 10:24:55 -0500 Subject: [PATCH 1/2] refactor(check): Make self check consistent with toolchain check --- src/cli/self_update.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index aec46b141c..2d1ad1234a 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -1399,19 +1399,21 @@ pub(crate) async fn check_rustup_update(dl_cfg: &DownloadCfg<'_>) -> Result {available_version}" + "{msg}{warn}{status}{warn:#} : {current_version} -> {available_version}" )?; true } else { - writeln!(t, "{green}Up to date{green:#} : {current_version}")?; + let status = "Up to date"; + writeln!(t, "{msg}{good}{status}{good:#} : {current_version}")?; false }) } From df7ceada53ac0f4097d16ca1e40d4830f8437f59 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 28 Oct 2025 10:46:06 -0500 Subject: [PATCH 2/2] fix(check): Adjust format of 'rustup check' to be like Cargo Discussed at https://rust-lang.zulipchat.com/#narrow/channel/490103-t-rustup/topic/rustup.2Fcargo.20output.20format.20consistency/near/546948974 --- src/cli/rustup_mode.rs | 23 ++++++------ src/cli/self_update.rs | 8 ++--- tests/suite/cli_exact.rs | 36 +++++++++---------- .../rustup_check_updates_none.stdout.term.svg | 6 ++-- .../rustup_check_updates_some.stdout.term.svg | 8 ++--- 5 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 570b61206f..58b2055991 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -832,10 +832,10 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result { MultiProgress::with_draw_target(cfg.process.progress_draw_target()); let semaphore = Arc::new(Semaphore::new(concurrent_downloads)); let channels = tokio_stream::iter(channels.into_iter()).map(|(name, distributable)| { - let msg = format!("{bold}{name} - {bold:#}"); - let status = "Checking..."; + let msg = format!("{bold}{name}{bold:#}"); + let status = " Checking"; let template = format!( - "{{msg}}{transient}{status}{transient:#} {transient}{{spinner}}{transient:#}" + "{transient}{status}{transient:#} {{msg}} {transient}{{spinner}}{transient:#}" ); let pb = multi_progress_bars.add(ProgressBar::new(1)); pb.set_style( @@ -855,22 +855,23 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result { let template = match (current_version, dist_version) { (None, None) => { - let status = "Cannot identify installed or update versions"; - format!("{msg}{error}{status}{error:#}") + let status = " Error for"; + let details = "cannot identify installed or update versions"; + format!("{status} {msg}: {error}{details}{error:#}") } (Some(cv), None) => { - let status = "up to date"; - format!("{msg}{good}{status}{good:#}: {cv}") + let status = " Up to date"; + format!("{good}{status}{good:#} {msg} {cv}") } (Some(cv), Some(dv)) => { - let status = "update available"; + let status = "Update available"; update_a = true; - format!("{msg}{warn}{status}{warn:#}: {cv} -> {dv}") + format!("{warn}{status}{warn:#} {msg} {cv} -> {dv}") } (None, Some(dv)) => { - let status = "update available"; + let status = "Update available"; update_a = true; - format!("{msg}{warn}{status}{warn:#}: (Unknown version) -> {dv}") + format!("{warn}{status}{warn:#} {msg} (Unknown version) -> {dv}") } }; pb.set_style(ProgressStyle::with_template(template.as_str()).unwrap()); diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 2d1ad1234a..827ee8755e 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -1402,18 +1402,18 @@ pub(crate) async fn check_rustup_update(dl_cfg: &DownloadCfg<'_>) -> Result {available_version}" + "{warn}{status}{warn:#} {msg} {current_version} -> {available_version}" )?; true } else { - let status = "Up to date"; - writeln!(t, "{msg}{good}{status}{good:#} : {current_version}")?; + let status = " Up to date"; + writeln!(t, "{good}{status}{good:#} {msg} {current_version}")?; false }) } diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index 196a9ac37f..f907a2725a 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -63,7 +63,7 @@ async fn update_once_and_check_self_update() { nightly-[HOST_TRIPLE] installed - 1.3.0 (hash-nightly-2) -rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION] +Update available rustup [CURRENT_VERSION] -> [TEST_VERSION] "#]]) .with_stderr(snapbox::str![[r#" @@ -184,9 +184,9 @@ async fn check_updates_none() { .await .is_err() .with_stdout(snapbox::str![[r#" -stable-[HOST_TRIPLE] - up to date: 1.1.0 (hash-stable-1.1.0) -beta-[HOST_TRIPLE] - up to date: 1.2.0 (hash-beta-1.2.0) -nightly-[HOST_TRIPLE] - up to date: 1.3.0 (hash-nightly-2) + Up to date stable-[HOST_TRIPLE] 1.1.0 (hash-stable-1.1.0) + Up to date beta-[HOST_TRIPLE] 1.2.0 (hash-beta-1.2.0) + Up to date nightly-[HOST_TRIPLE] 1.3.0 (hash-nightly-2) "#]]); } @@ -209,9 +209,9 @@ async fn check_updates_some() { .await .is_ok() .with_stdout(snapbox::str![[r#" -stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) -beta-[HOST_TRIPLE] - update available: 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0) -nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) +Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) +Update available beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0) +Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) "#]]); } @@ -234,7 +234,7 @@ async fn check_updates_self() { .extend_redactions([("[TEST_VERSION]", test_version)]) .is_ok() .with_stdout(snapbox::str![[r#" -rustup - Update available : [CURRENT_VERSION] -> [TEST_VERSION] +Update available rustup [CURRENT_VERSION] -> [TEST_VERSION] "#]]); } @@ -256,7 +256,7 @@ async fn check_updates_self_no_change() { .await .is_err() .with_stdout(snapbox::str![[r#" -rustup - Up to date : [CURRENT_VERSION] + Up to date rustup [CURRENT_VERSION] "#]]); } @@ -276,9 +276,9 @@ async fn check_updates_with_update() { .await .is_err() .with_stdout(snapbox::str![[r#" -stable-[HOST_TRIPLE] - up to date: 1.0.0 (hash-stable-1.0.0) -beta-[HOST_TRIPLE] - up to date: 1.1.0 (hash-beta-1.1.0) -nightly-[HOST_TRIPLE] - up to date: 1.2.0 (hash-nightly-1) + Up to date stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) + Up to date beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0) + Up to date nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) "#]]); } @@ -289,9 +289,9 @@ nightly-[HOST_TRIPLE] - up to date: 1.2.0 (hash-nightly-1) .await .is_ok() .with_stdout(snapbox::str![[r#" -stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) -beta-[HOST_TRIPLE] - update available: 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0) -nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) +Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) +Update available beta-[HOST_TRIPLE] 1.1.0 (hash-beta-1.1.0) -> 1.2.0 (hash-beta-1.2.0) +Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) "#]]); cx.config.expect(["rustup", "update", "beta"]).await.is_ok(); @@ -300,9 +300,9 @@ nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash- .await .is_ok() .with_stdout(snapbox::str![[r#" -stable-[HOST_TRIPLE] - update available: 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) -beta-[HOST_TRIPLE] - up to date: 1.2.0 (hash-beta-1.2.0) -nightly-[HOST_TRIPLE] - update available: 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) +Update available stable-[HOST_TRIPLE] 1.0.0 (hash-stable-1.0.0) -> 1.1.0 (hash-stable-1.1.0) + Up to date beta-[HOST_TRIPLE] 1.2.0 (hash-beta-1.2.0) +Update available nightly-[HOST_TRIPLE] 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2) "#]]); } diff --git a/tests/suite/cli_rustup_ui/rustup_check_updates_none.stdout.term.svg b/tests/suite/cli_rustup_ui/rustup_check_updates_none.stdout.term.svg index 1e9b9229ef..5a281b04c4 100644 --- a/tests/suite/cli_rustup_ui/rustup_check_updates_none.stdout.term.svg +++ b/tests/suite/cli_rustup_ui/rustup_check_updates_none.stdout.term.svg @@ -18,11 +18,11 @@ - stable-[HOST_TRIPLE] - up to date: 1.1.0 (hash-stable-1.1.0) + Up to date stable-[HOST_TRIPLE] 1.1.0 (hash-stable-1.1.0) - beta-[HOST_TRIPLE] - up to date: 1.2.0 (hash-beta-1.2.0) + Up to date beta-[HOST_TRIPLE] 1.2.0 (hash-beta-1.2.0) - nightly-[HOST_TRIPLE] - up to date: 1.3.0 (hash-nightly-2) + Up to date nightly-[HOST_TRIPLE] 1.3.0 (hash-nightly-2) diff --git a/tests/suite/cli_rustup_ui/rustup_check_updates_some.stdout.term.svg b/tests/suite/cli_rustup_ui/rustup_check_updates_some.stdout.term.svg index 0bd67b78d0..7f08732f68 100644 --- a/tests/suite/cli_rustup_ui/rustup_check_updates_some.stdout.term.svg +++ b/tests/suite/cli_rustup_ui/rustup_check_updates_some.stdout.term.svg @@ -1,4 +1,4 @@ - +