Skip to content

Commit b50884f

Browse files
committed
test(cli_v2): introduce update_removed_component_toolchain()
1 parent ca7cf93 commit b50884f

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
@@ -94,6 +94,8 @@ pub enum Scenario {
9494
Unavailable,
9595
/// Two dates, v2 manifests, RLS unavailable in first date, restored on second.
9696
UnavailableRls,
97+
/// Two dates, v2 manifests, RLS available in first stable, removed on second.
98+
RemovedRls,
9799
/// Three dates, v2 manifests, RLS available in first and second, not last
98100
MissingComponent,
99101
/// Three dates, v2 manifests, RLS available in first, middle missing nightly
@@ -153,6 +155,7 @@ impl ConstState {
153155
Scenario::MissingNightly => RwLock::new(None),
154156
Scenario::MultiHost => RwLock::new(None),
155157
Scenario::None => RwLock::new(None),
158+
Scenario::RemovedRls => RwLock::new(None),
156159
Scenario::SimpleV1 => RwLock::new(None),
157160
Scenario::SimpleV2 => RwLock::new(None),
158161
Scenario::Unavailable => RwLock::new(None),
@@ -1160,6 +1163,10 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
11601163
Release::stable("1.1.0", "2015-01-02"),
11611164
]
11621165
}
1166+
Scenario::RemovedRls => vec![
1167+
Release::stable("1.78.0", "2024-05-01"),
1168+
Release::stable("1.79.0", "2024-06-15").with_rls(RlsStatus::Unavailable),
1169+
],
11631170
Scenario::SimpleV1 | Scenario::SimpleV2 => vec![
11641171
Release::new("nightly", "1.3.0", "2015-01-02", "2").with_rls(RlsStatus::Renamed),
11651172
Release::beta("1.2.0", "2015-01-02"),
@@ -1207,6 +1214,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
12071214
| Scenario::MultiHost
12081215
| Scenario::Unavailable
12091216
| Scenario::UnavailableRls
1217+
| Scenario::RemovedRls
12101218
| Scenario::MissingNightly
12111219
| Scenario::HostGoesMissingBefore
12121220
| Scenario::HostGoesMissingAfter

tests/suite/cli_v2.rs

+44
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,50 @@ Then you can use the toolchain with commands such as:
13621362
).await;
13631363
}
13641364

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

0 commit comments

Comments
 (0)