Skip to content

Commit 1b01e8b

Browse files
committed
fix(cli/rustup-mode): make rustup show active-toolchain exit with 1 when none is active
1 parent 21c1bfa commit 1b01e8b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/cli/rustup_mode.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,7 @@ fn show_active_toolchain(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode
10961096
)?;
10971097
}
10981098
}
1099-
None => writeln!(
1100-
cfg.process.stdout().lock(),
1101-
"There isn't an active toolchain"
1102-
)?,
1099+
None => return Err(anyhow!("there isn't an active toolchain")),
11031100
}
11041101
Ok(utils::ExitCode(0))
11051102
}

tests/suite/cli_rustup.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1281,12 +1281,12 @@ async fn show_active_toolchain_with_override() {
12811281

12821282
#[tokio::test]
12831283
async fn show_active_toolchain_none() {
1284-
let mut cx = CliTestContext::new(Scenario::None).await;
1284+
let cx = CliTestContext::new(Scenario::None).await;
12851285
cx.config
1286-
.expect_ok_ex(
1286+
.expect_err_ex(
12871287
&["rustup", "show", "active-toolchain"],
1288-
"There isn't an active toolchain\n",
12891288
"",
1289+
"error: there isn't an active toolchain\n",
12901290
)
12911291
.await;
12921292
}
@@ -2358,9 +2358,10 @@ async fn override_order() {
23582358
// No default
23592359
cx.config.expect_ok(&["rustup", "default", "none"]).await;
23602360
cx.config
2361-
.expect_stdout_ok(
2361+
.expect_err_ex(
23622362
&["rustup", "show", "active-toolchain"],
2363-
"There isn't an active toolchain\n",
2363+
"",
2364+
"error: there isn't an active toolchain\n",
23642365
)
23652366
.await;
23662367

0 commit comments

Comments
 (0)