@@ -1366,6 +1366,63 @@ fn add_component() {
1366
1366
} ) ;
1367
1367
}
1368
1368
1369
+ #[ test]
1370
+ fn add_component_by_target_triple ( ) {
1371
+ test ( & |config| {
1372
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1373
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1374
+ config. expect_ok ( & [
1375
+ "rustup" ,
1376
+ "component" ,
1377
+ "add" ,
1378
+ & format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ,
1379
+ ] ) ;
1380
+ let path = format ! (
1381
+ "toolchains/stable-{}/lib/rustlib/{}/lib/libstd.rlib" ,
1382
+ this_host_triple( ) ,
1383
+ clitools:: CROSS_ARCH1
1384
+ ) ;
1385
+ assert ! ( config. rustupdir. has( path) ) ;
1386
+ } )
1387
+ } ) ;
1388
+ }
1389
+
1390
+ #[ test]
1391
+ fn fail_invalid_component_name ( ) {
1392
+ test ( & |config| {
1393
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1394
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1395
+ config. expect_err (
1396
+ & [
1397
+ "rustup" ,
1398
+ "component" ,
1399
+ "add" ,
1400
+ & format ! ( "dummy-{}" , clitools:: CROSS_ARCH1 ) ,
1401
+ ] ,
1402
+ & format ! ( "error: toolchain 'stable-{}' does not contain component 'dummy-{}' for target '{}'" , this_host_triple( ) , clitools:: CROSS_ARCH1 , this_host_triple( ) ) ,
1403
+ ) ;
1404
+ } )
1405
+ } ) ;
1406
+ }
1407
+
1408
+ #[ test]
1409
+ fn fail_invalid_component_target ( ) {
1410
+ test ( & |config| {
1411
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1412
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1413
+ config. expect_err (
1414
+ & [
1415
+ "rustup" ,
1416
+ "component" ,
1417
+ "add" ,
1418
+ "rust-std-invalid-target" ,
1419
+ ] ,
1420
+ & format ! ( "error: toolchain 'stable-{}' does not contain component 'rust-std-invalid-target' for target '{}'" , this_host_triple( ) , this_host_triple( ) ) ,
1421
+ ) ;
1422
+ } )
1423
+ } ) ;
1424
+ }
1425
+
1369
1426
#[ test]
1370
1427
fn remove_component ( ) {
1371
1428
test ( & |config| {
@@ -1383,22 +1440,61 @@ fn remove_component() {
1383
1440
} ) ;
1384
1441
}
1385
1442
1443
+ #[ test]
1444
+ fn remove_component_by_target_triple ( ) {
1445
+ let component_with_triple = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ;
1446
+ test ( & |config| {
1447
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1448
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1449
+ config. expect_ok ( & [ "rustup" , "component" , "add" , & component_with_triple] ) ;
1450
+ let path = PathBuf :: from ( format ! (
1451
+ "toolchains/stable-{}/lib/rustlib/{}/lib/libstd.rlib" ,
1452
+ this_host_triple( ) ,
1453
+ clitools:: CROSS_ARCH1
1454
+ ) ) ;
1455
+ assert ! ( config. rustupdir. has( & path) ) ;
1456
+ config. expect_ok ( & [ "rustup" , "component" , "remove" , & component_with_triple] ) ;
1457
+ assert ! ( !config. rustupdir. has( path. parent( ) . unwrap( ) ) ) ;
1458
+ } )
1459
+ } ) ;
1460
+ }
1461
+
1386
1462
#[ test]
1387
1463
fn add_remove_multiple_components ( ) {
1388
1464
let files = [
1389
1465
"lib/rustlib/src/rust-src/foo.rs" . to_owned ( ) ,
1390
1466
format ! ( "lib/rustlib/{}/analysis/libfoo.json" , this_host_triple( ) ) ,
1467
+ format ! ( "lib/rustlib/{}/lib/libstd.rlib" , clitools:: CROSS_ARCH1 ) ,
1468
+ format ! ( "lib/rustlib/{}/lib/libstd.rlib" , clitools:: CROSS_ARCH2 ) ,
1391
1469
] ;
1470
+ let component_with_triple1 = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ;
1471
+ let component_with_triple2 = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH2 ) ;
1392
1472
1393
1473
test ( & |config| {
1394
1474
config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1395
1475
config. expect_ok ( & [ "rustup" , "default" , "nightly" ] ) ;
1396
- config. expect_ok ( & [ "rustup" , "component" , "add" , "rust-src" , "rust-analysis" ] ) ;
1476
+ config. expect_ok ( & [
1477
+ "rustup" ,
1478
+ "component" ,
1479
+ "add" ,
1480
+ "rust-src" ,
1481
+ "rust-analysis" ,
1482
+ & component_with_triple1,
1483
+ & component_with_triple2,
1484
+ ] ) ;
1397
1485
for file in & files {
1398
1486
let path = format ! ( "toolchains/nightly-{}/{}" , this_host_triple( ) , file) ;
1399
1487
assert ! ( config. rustupdir. has( & path) ) ;
1400
1488
}
1401
- config. expect_ok ( & [ "rustup" , "component" , "remove" , "rust-src" , "rust-analysis" ] ) ;
1489
+ config. expect_ok ( & [
1490
+ "rustup" ,
1491
+ "component" ,
1492
+ "remove" ,
1493
+ "rust-src" ,
1494
+ "rust-analysis" ,
1495
+ & component_with_triple1,
1496
+ & component_with_triple2,
1497
+ ] ) ;
1402
1498
for file in & files {
1403
1499
let path = PathBuf :: from ( format ! (
1404
1500
"toolchains/nightly-{}/{}" ,
0 commit comments