Skip to content

Commit

Permalink
fix(cli/rustup-mode): make rustup show active-toolchain exit with `…
Browse files Browse the repository at this point in the history
…1` when none is active
  • Loading branch information
rami3l committed Jan 4, 2025
1 parent e17902d commit d81c19c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,7 @@ fn show_active_toolchain(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode
)?;
}
}
None => writeln!(
cfg.process.stdout().lock(),
"There isn't an active toolchain"
)?,
None => return Err(anyhow!("there isn't an active toolchain")),
}
Ok(utils::ExitCode(0))
}
Expand Down
11 changes: 6 additions & 5 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,12 +1281,12 @@ async fn show_active_toolchain_with_override() {

#[tokio::test]
async fn show_active_toolchain_none() {
let mut cx = CliTestContext::new(Scenario::None).await;
let cx = CliTestContext::new(Scenario::None).await;
cx.config
.expect_ok_ex(
.expect_err_ex(
&["rustup", "show", "active-toolchain"],
"There isn't an active toolchain\n",
"",
"error: there isn't an active toolchain\n",
)
.await;
}
Expand Down Expand Up @@ -2358,9 +2358,10 @@ async fn override_order() {
// No default
cx.config.expect_ok(&["rustup", "default", "none"]).await;
cx.config
.expect_stdout_ok(
.expect_err_ex(
&["rustup", "show", "active-toolchain"],
"There isn't an active toolchain\n",
"",
"error: there isn't an active toolchain\n",
)
.await;

Expand Down

0 comments on commit d81c19c

Please sign in to comment.