@@ -1384,6 +1384,93 @@ fn file_override() {
1384
1384
} ) ;
1385
1385
}
1386
1386
1387
+ #[ test]
1388
+ #[ cfg_attr(
1389
+ not( unix) ,
1390
+ ignore = "TODO: Figure out how to write a wrapper toolchain on Windows"
1391
+ ) ]
1392
+ fn file_override_path ( ) {
1393
+ setup ( & |config| {
1394
+ let cwd = config. current_dir ( ) ;
1395
+ let toolchain_path = cwd. join ( "ephemeral" ) ;
1396
+ let toolchain_bin = toolchain_path. join ( "bin" ) ;
1397
+ fs:: create_dir_all ( & toolchain_bin) . unwrap ( ) ;
1398
+
1399
+ // Inject a wrapper binary for rustc.
1400
+ let rustc = toolchain_bin. join ( "rustc" ) ;
1401
+ #[ cfg( unix) ]
1402
+ {
1403
+ use std:: os:: unix:: fs:: PermissionsExt ;
1404
+ raw:: write_file ( & rustc, "#!/bin/sh\n echo custom-toolchain" ) . unwrap ( ) ;
1405
+ fs:: set_permissions ( rustc, fs:: Permissions :: from_mode ( 0o755 ) ) . unwrap ( ) ;
1406
+ }
1407
+
1408
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
1409
+ raw:: write_file (
1410
+ & toolchain_file,
1411
+ & format ! ( "[toolchain]\n path=\" {}\" " , toolchain_path. display( ) ) ,
1412
+ )
1413
+ . unwrap ( ) ;
1414
+
1415
+ expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "custom-toolchain" ) ;
1416
+ } ) ;
1417
+ }
1418
+
1419
+ #[ test]
1420
+ #[ cfg_attr(
1421
+ not( unix) ,
1422
+ ignore = "TODO: Figure out how to write a wrapper toolchain on Windows"
1423
+ ) ]
1424
+ fn file_override_path_relative ( ) {
1425
+ setup ( & |config| {
1426
+ let cwd = config. current_dir ( ) ;
1427
+ let toolchain_path = cwd. join ( "ephemeral" ) ;
1428
+ let toolchain_bin = toolchain_path. join ( "bin" ) ;
1429
+ fs:: create_dir_all ( & toolchain_bin) . unwrap ( ) ;
1430
+
1431
+ // Inject a wrapper binary for rustc.
1432
+ let rustc = toolchain_bin. join ( "rustc" ) ;
1433
+ #[ cfg( unix) ]
1434
+ {
1435
+ use std:: os:: unix:: fs:: PermissionsExt ;
1436
+ raw:: write_file ( & rustc, "#!/bin/sh\n echo custom-toolchain" ) . unwrap ( ) ;
1437
+ fs:: set_permissions ( rustc, fs:: Permissions :: from_mode ( 0o755 ) ) . unwrap ( ) ;
1438
+ }
1439
+
1440
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
1441
+ raw:: write_file ( & toolchain_file, "[toolchain]\n path=\" ephemeral\" " ) . unwrap ( ) ;
1442
+
1443
+ // Change into ephemeral so that we actually test that the path is relative to the override
1444
+ config. change_dir ( & toolchain_path, || {
1445
+ expect_stdout_ok ( config, & [ "rustc" , "--version" ] , "custom-toolchain" )
1446
+ } ) ;
1447
+ } ) ;
1448
+ }
1449
+
1450
+ #[ test]
1451
+ fn file_override_path_xor_channel ( ) {
1452
+ setup ( & |config| {
1453
+ // Make a plausible-looking toolchain
1454
+ let cwd = config. current_dir ( ) ;
1455
+ let toolchain_path = cwd. join ( "ephemeral" ) ;
1456
+ let toolchain_bin = toolchain_path. join ( "bin" ) ;
1457
+ fs:: create_dir_all ( & toolchain_bin) . unwrap ( ) ;
1458
+
1459
+ let toolchain_file = cwd. join ( "rust-toolchain.toml" ) ;
1460
+ raw:: write_file (
1461
+ & toolchain_file,
1462
+ "[toolchain]\n path=\" ephemeral\" \n channel=\" nightly\" " ,
1463
+ )
1464
+ . unwrap ( ) ;
1465
+
1466
+ expect_err (
1467
+ config,
1468
+ & [ "rustc" , "--version" ] ,
1469
+ "cannot specify both channel (nightly) and path (ephemeral) simultaneously" ,
1470
+ ) ;
1471
+ } ) ;
1472
+ }
1473
+
1387
1474
#[ test]
1388
1475
fn file_override_subdir ( ) {
1389
1476
setup ( & |config| {
0 commit comments