diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index aa041bd4a54..d81eb0374b6 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -93,6 +93,8 @@ pub enum Scenario { Unavailable, /// Two dates, v2 manifests, RLS unavailable in first date, restored on second. UnavailableRls, + /// Two dates, v2 manifests, RLS available in first stable, removed on second. + RemovedRls, /// Three dates, v2 manifests, RLS available in first and second, not last MissingComponent, /// Three dates, v2 manifests, RLS available in first, middle missing nightly @@ -152,6 +154,7 @@ impl ConstState { Scenario::MissingNightly => RwLock::new(None), Scenario::MultiHost => RwLock::new(None), Scenario::None => RwLock::new(None), + Scenario::RemovedRls => RwLock::new(None), Scenario::SimpleV1 => RwLock::new(None), Scenario::SimpleV2 => RwLock::new(None), Scenario::Unavailable => RwLock::new(None), @@ -1152,6 +1155,10 @@ fn create_mock_dist_server(path: &Path, s: Scenario) { Release::stable("1.1.0", "2015-01-02"), ] } + Scenario::RemovedRls => vec![ + Release::stable("1.78.0", "2024-05-01"), + Release::stable("1.79.0", "2024-06-15").with_rls(RlsStatus::Unavailable), + ], Scenario::SimpleV1 | Scenario::SimpleV2 => vec![ Release::new("nightly", "1.3.0", "2015-01-02", "2").with_rls(RlsStatus::Renamed), Release::beta("1.2.0", "2015-01-02"), @@ -1199,6 +1206,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) { | Scenario::MultiHost | Scenario::Unavailable | Scenario::UnavailableRls + | Scenario::RemovedRls | Scenario::MissingNightly | Scenario::HostGoesMissingBefore | Scenario::HostGoesMissingAfter diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index f99b2044b2e..0dcd81d5eea 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -1378,6 +1378,50 @@ Then you can use the toolchain with commands such as: ).await; } +#[tokio::test] +async fn update_removed_component_toolchain() { + let mut cx = CliTestContext::new(Scenario::RemovedRls).await; + set_current_dist_date(&cx.config, "2024-05-01"); + cx.config.expect_ok(&["rustup", "default", "stable"]).await; + + // Install `rls` on the first day. + cx.config + .expect_stdout_ok(&["rustc", "--version"], "1.78.0") + .await; + cx.config + .expect_ok(&["rustup", "component", "add", "rls"]) + .await; + cx.config.expect_component_executable("rls").await; + + // `rls` is missing on the second day. + set_current_dist_date(&cx.config, "2024-06-15"); + + // An update at this time should inform the user of an unavailable component. + cx.config + .expect_err( + &["rustup", "update", "stable"], + for_host!( + r"component 'rls' for target '{0}' is unavailable for download for channel 'stable' +One or many components listed above might have been permanently removed from newer versions +of the official Rust distribution due to deprecation. + +If you are updating an existing toolchain, after determining the deprecated component(s) +in question, please remove them with a command such as: + + rustup component remove --toolchain stable ... + +After that, you should be able to continue with the update as usual." + ), + ) + .await; + + // We're still stuck with the old version. + cx.config + .expect_stdout_ok(&["rustc", "--version"], "1.78.0") + .await; + cx.config.expect_component_executable("rls").await; +} + #[tokio::test] async fn update_unavailable_force() { let mut cx = CliTestContext::new(Scenario::SimpleV2).await;