@@ -1384,6 +1384,70 @@ async fn which_asking_uninstalled_toolchain() {
1384
1384
. is_ok ( ) ;
1385
1385
}
1386
1386
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
+
1387
1451
#[ tokio:: test]
1388
1452
async fn override_by_toolchain_on_the_command_line ( ) {
1389
1453
let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
0 commit comments