Skip to content

Commit

Permalink
test(cli_v2): introduce update_removed_component_toolchain()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Aug 12, 2024
1 parent 2e36a61 commit 5667e49
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/mock/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <COMPONENT>...
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;
Expand Down

0 comments on commit 5667e49

Please sign in to comment.