Skip to content

Commit 1f976a6

Browse files
committed
test(cli_v2): introduce update_removed_component_toolchain()
1 parent f20255a commit 1f976a6

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/test/mock/clitools.rs

+8
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ pub enum Scenario {
9393
Unavailable,
9494
/// Two dates, v2 manifests, RLS unavailable in first date, restored on second.
9595
UnavailableRls,
96+
/// Two dates, v2 manifests, RLS available in first stable, removed on second.
97+
RemovedRls,
9698
/// Three dates, v2 manifests, RLS available in first and second, not last
9799
MissingComponent,
98100
/// Three dates, v2 manifests, RLS available in first, middle missing nightly
@@ -152,6 +154,7 @@ impl ConstState {
152154
Scenario::MissingNightly => RwLock::new(None),
153155
Scenario::MultiHost => RwLock::new(None),
154156
Scenario::None => RwLock::new(None),
157+
Scenario::RemovedRls => RwLock::new(None),
155158
Scenario::SimpleV1 => RwLock::new(None),
156159
Scenario::SimpleV2 => RwLock::new(None),
157160
Scenario::Unavailable => RwLock::new(None),
@@ -1152,6 +1155,10 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
11521155
Release::stable("1.1.0", "2015-01-02"),
11531156
]
11541157
}
1158+
Scenario::RemovedRls => vec![
1159+
Release::stable("1.78.0", "2024-05-01"),
1160+
Release::stable("1.79.0", "2024-06-15").with_rls(RlsStatus::Unavailable),
1161+
],
11551162
Scenario::SimpleV1 | Scenario::SimpleV2 => vec![
11561163
Release::new("nightly", "1.3.0", "2015-01-02", "2").with_rls(RlsStatus::Renamed),
11571164
Release::beta("1.2.0", "2015-01-02"),
@@ -1199,6 +1206,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
11991206
| Scenario::MultiHost
12001207
| Scenario::Unavailable
12011208
| Scenario::UnavailableRls
1209+
| Scenario::RemovedRls
12021210
| Scenario::MissingNightly
12031211
| Scenario::HostGoesMissingBefore
12041212
| Scenario::HostGoesMissingAfter

tests/suite/cli_v2.rs

+44
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,50 @@ Then you can use the toolchain with commands such as:
13781378
).await;
13791379
}
13801380

1381+
#[tokio::test]
1382+
async fn update_removed_component_toolchain() {
1383+
let mut cx = CliTestContext::new(Scenario::RemovedRls).await;
1384+
set_current_dist_date(&cx.config, "2024-05-01");
1385+
cx.config.expect_ok(&["rustup", "default", "stable"]).await;
1386+
1387+
// Install `rls` on the first day.
1388+
cx.config
1389+
.expect_stdout_ok(&["rustc", "--version"], "1.78.0")
1390+
.await;
1391+
cx.config
1392+
.expect_ok(&["rustup", "component", "add", "rls"])
1393+
.await;
1394+
cx.config.expect_component_executable("rls").await;
1395+
1396+
// `rls` is missing on the second day.
1397+
set_current_dist_date(&cx.config, "2024-06-15");
1398+
1399+
// An update at this time should inform the user of an unavailable component.
1400+
cx.config
1401+
.expect_err(
1402+
&["rustup", "update", "stable"],
1403+
for_host!(
1404+
r"component 'rls' for target '{0}' is unavailable for download for channel 'stable'
1405+
One or many components listed above might have been permanently removed from newer versions
1406+
of the official Rust distribution due to deprecation.
1407+
1408+
If you are updating an existing toolchain, after determining the deprecated component(s)
1409+
in question, please remove them with a command such as:
1410+
1411+
rustup component remove --toolchain stable <COMPONENT>...
1412+
1413+
After that, you should be able to continue with the update as usual."
1414+
),
1415+
)
1416+
.await;
1417+
1418+
// We're still stuck with the old version.
1419+
cx.config
1420+
.expect_stdout_ok(&["rustc", "--version"], "1.78.0")
1421+
.await;
1422+
cx.config.expect_component_executable("rls").await;
1423+
}
1424+
13811425
#[tokio::test]
13821426
async fn update_unavailable_force() {
13831427
let mut cx = CliTestContext::new(Scenario::SimpleV2).await;

0 commit comments

Comments
 (0)