@@ -1352,6 +1352,63 @@ fn add_component() {
1352
1352
} ) ;
1353
1353
}
1354
1354
1355
+ #[ test]
1356
+ fn add_component_by_target_triple ( ) {
1357
+ test ( & |config| {
1358
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1359
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1360
+ config. expect_ok ( & [
1361
+ "rustup" ,
1362
+ "component" ,
1363
+ "add" ,
1364
+ & format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ,
1365
+ ] ) ;
1366
+ let path = format ! (
1367
+ "toolchains/stable-{}/lib/rustlib/{}/lib/libstd.rlib" ,
1368
+ this_host_triple( ) ,
1369
+ clitools:: CROSS_ARCH1
1370
+ ) ;
1371
+ assert ! ( config. rustupdir. has( path) ) ;
1372
+ } )
1373
+ } ) ;
1374
+ }
1375
+
1376
+ #[ test]
1377
+ fn fail_invalid_component_name ( ) {
1378
+ test ( & |config| {
1379
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1380
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1381
+ config. expect_err (
1382
+ & [
1383
+ "rustup" ,
1384
+ "component" ,
1385
+ "add" ,
1386
+ & format ! ( "dummy-{}" , clitools:: CROSS_ARCH1 ) ,
1387
+ ] ,
1388
+ & format ! ( "error: toolchain 'stable-{}' does not contain component 'dummy-{}' for target '{}'" , this_host_triple( ) , clitools:: CROSS_ARCH1 , this_host_triple( ) ) ,
1389
+ ) ;
1390
+ } )
1391
+ } ) ;
1392
+ }
1393
+
1394
+ #[ test]
1395
+ fn fail_invalid_component_target ( ) {
1396
+ test ( & |config| {
1397
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1398
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1399
+ config. expect_err (
1400
+ & [
1401
+ "rustup" ,
1402
+ "component" ,
1403
+ "add" ,
1404
+ "rust-std-invalid-target" ,
1405
+ ] ,
1406
+ & format ! ( "error: toolchain 'stable-{}' does not contain component 'rust-std-invalid-target' for target '{}'" , this_host_triple( ) , this_host_triple( ) ) ,
1407
+ ) ;
1408
+ } )
1409
+ } ) ;
1410
+ }
1411
+
1355
1412
#[ test]
1356
1413
fn remove_component ( ) {
1357
1414
test ( & |config| {
@@ -1369,22 +1426,61 @@ fn remove_component() {
1369
1426
} ) ;
1370
1427
}
1371
1428
1429
+ #[ test]
1430
+ fn remove_component_by_target_triple ( ) {
1431
+ let component_with_triple = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ;
1432
+ test ( & |config| {
1433
+ config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1434
+ config. expect_ok ( & [ "rustup" , "default" , "stable" ] ) ;
1435
+ config. expect_ok ( & [ "rustup" , "component" , "add" , & component_with_triple] ) ;
1436
+ let path = PathBuf :: from ( format ! (
1437
+ "toolchains/stable-{}/lib/rustlib/{}/lib/libstd.rlib" ,
1438
+ this_host_triple( ) ,
1439
+ clitools:: CROSS_ARCH1
1440
+ ) ) ;
1441
+ assert ! ( config. rustupdir. has( & path) ) ;
1442
+ config. expect_ok ( & [ "rustup" , "component" , "remove" , & component_with_triple] ) ;
1443
+ assert ! ( !config. rustupdir. has( path. parent( ) . unwrap( ) ) ) ;
1444
+ } )
1445
+ } ) ;
1446
+ }
1447
+
1372
1448
#[ test]
1373
1449
fn add_remove_multiple_components ( ) {
1374
1450
let files = [
1375
1451
"lib/rustlib/src/rust-src/foo.rs" . to_owned ( ) ,
1376
1452
format ! ( "lib/rustlib/{}/analysis/libfoo.json" , this_host_triple( ) ) ,
1453
+ format ! ( "lib/rustlib/{}/lib/libstd.rlib" , clitools:: CROSS_ARCH1 ) ,
1454
+ format ! ( "lib/rustlib/{}/lib/libstd.rlib" , clitools:: CROSS_ARCH2 ) ,
1377
1455
] ;
1456
+ let component_with_triple1 = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH1 ) ;
1457
+ let component_with_triple2 = format ! ( "rust-std-{}" , clitools:: CROSS_ARCH2 ) ;
1378
1458
1379
1459
test ( & |config| {
1380
1460
config. with_scenario ( Scenario :: SimpleV2 , & |config| {
1381
1461
config. expect_ok ( & [ "rustup" , "default" , "nightly" ] ) ;
1382
- config. expect_ok ( & [ "rustup" , "component" , "add" , "rust-src" , "rust-analysis" ] ) ;
1462
+ config. expect_ok ( & [
1463
+ "rustup" ,
1464
+ "component" ,
1465
+ "add" ,
1466
+ "rust-src" ,
1467
+ "rust-analysis" ,
1468
+ & component_with_triple1,
1469
+ & component_with_triple2,
1470
+ ] ) ;
1383
1471
for file in & files {
1384
1472
let path = format ! ( "toolchains/nightly-{}/{}" , this_host_triple( ) , file) ;
1385
1473
assert ! ( config. rustupdir. has( & path) ) ;
1386
1474
}
1387
- config. expect_ok ( & [ "rustup" , "component" , "remove" , "rust-src" , "rust-analysis" ] ) ;
1475
+ config. expect_ok ( & [
1476
+ "rustup" ,
1477
+ "component" ,
1478
+ "remove" ,
1479
+ "rust-src" ,
1480
+ "rust-analysis" ,
1481
+ & component_with_triple1,
1482
+ & component_with_triple2,
1483
+ ] ) ;
1388
1484
for file in & files {
1389
1485
let path = PathBuf :: from ( format ! (
1390
1486
"toolchains/nightly-{}/{}" ,
0 commit comments