From f48df22e9dfaf44c2e438c4e7e8b358333cd6b31 Mon Sep 17 00:00:00 2001 From: Xerxes-2 Date: Wed, 26 Jun 2024 17:51:49 +1000 Subject: [PATCH] add regression tests for smart guess --- tests/suite/cli_misc.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 5359e6afbd..3dee46f337 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -1180,3 +1180,27 @@ async fn toolchain_link_then_list_verbose() { .expect_stdout_ok(&["rustup", "toolchain", "list", "-v"], "/custom-1") .await; } + +#[tokio::test] +async fn update_self_smart_guess() { + let cx = CliTestContext::new(Scenario::SimpleV2).await; + let out = cx.config.run("rustup", &["update", "self"], &[]).await; + let invalid_toolchain = out.stderr.contains("invalid toolchain name"); + if !out.ok && invalid_toolchain { + assert!(out + .stderr + .contains("if you meant to update rustup itself, use `rustup self update`")) + } +} + +#[tokio::test] +async fn uninstall_self_smart_guess() { + let cx = CliTestContext::new(Scenario::SimpleV2).await; + let out = cx.config.run("rustup", &["uninstall", "self"], &[]).await; + let no_toolchain_installed = out.stdout.contains("no toolchain installed"); + if out.ok && no_toolchain_installed { + assert!(out + .stdout + .contains("if you meant to uninstall rustup itself, use `rustup self uninstall`")) + } +}