Skip to content

Commit dfc0e30

Browse files
committed
test(cli_misc): more tests for rustup which
includes these cases: - ask binary included by uninstalled component - ask binary included by uninstalled component with non-default toolchain - ask binary not known to be included by what toolchain
1 parent aa79802 commit dfc0e30

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

tests/suite/cli_misc.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,70 @@ async fn which_asking_uninstalled_toolchain() {
13841384
.is_ok();
13851385
}
13861386

1387+
#[tokio::test]
1388+
async fn which_asking_uninstalled_components() {
1389+
let cx = CliTestContext::new(Scenario::SimpleV2).await;
1390+
1391+
let path_1 = cx.config.customdir.join("custom-1");
1392+
let path_1 = path_1.to_string_lossy();
1393+
cx.config
1394+
.expect(["rustup", "toolchain", "link", "custom-1", &path_1])
1395+
.await
1396+
.is_ok();
1397+
cx.config
1398+
.expect(["rustup", "default", "custom-1"])
1399+
.await
1400+
.is_ok();
1401+
cx.config
1402+
.expect(["rustup", "which", "rustfmt"])
1403+
.await
1404+
.with_stderr(snapbox::str![[r#"
1405+
error: 'rustfmt' is not installed for the toolchain 'custom-1'.
1406+
[..]`rustup component add rustfmt`
1407+
1408+
"#]])
1409+
.is_err();
1410+
1411+
let path_2 = cx.config.customdir.join("custom-2");
1412+
let path_2 = path_2.to_string_lossy();
1413+
cx.config
1414+
.expect(["rustup", "toolchain", "link", "custom-2", &path_2])
1415+
.await
1416+
.is_ok();
1417+
cx.config
1418+
.expect(["rustup", "which", "--toolchain=custom-2", "rustfmt"])
1419+
.await
1420+
.with_stderr(snapbox::str![[r#"
1421+
[..]'rustfmt' is not installed for the toolchain 'custom-2'.
1422+
[..]`rustup component add --toolchain custom-2 rustfmt`
1423+
1424+
"#]])
1425+
.is_err();
1426+
}
1427+
1428+
#[tokio::test]
1429+
async fn which_unknown_binary() {
1430+
let cx = CliTestContext::new(Scenario::SimpleV2).await;
1431+
let path_1 = cx.config.customdir.join("custom-1");
1432+
let path_1 = path_1.to_string_lossy();
1433+
cx.config
1434+
.expect(["rustup", "toolchain", "link", "custom-1", &path_1])
1435+
.await
1436+
.is_ok();
1437+
cx.config
1438+
.expect(["rustup", "default", "custom-1"])
1439+
.await
1440+
.is_ok();
1441+
cx.config
1442+
.expect(["rustup", "which", "ls"])
1443+
.await
1444+
.with_stderr(snapbox::str![[r#"
1445+
[..]unknown binary 'ls' in toolchain 'custom-1'
1446+
1447+
"#]])
1448+
.is_err();
1449+
}
1450+
13871451
#[tokio::test]
13881452
async fn override_by_toolchain_on_the_command_line() {
13891453
let cx = CliTestContext::new(Scenario::SimpleV2).await;

0 commit comments

Comments
 (0)