@@ -1499,6 +1499,42 @@ installed targets:
14991499 . is_ok ( ) ;
15001500}
15011501
1502+ #[ cfg( unix) ]
1503+ #[ tokio:: test]
1504+ async fn show_active_toolchain_rustc_permission_denied ( ) {
1505+ use std:: os:: unix:: fs:: PermissionsExt ;
1506+
1507+ let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
1508+ let path = cx. config . customdir . join ( "custom-1" ) ;
1509+ let path_str = path. to_string_lossy ( ) ;
1510+ cx. config
1511+ . expect ( [ "rustup" , "toolchain" , "link" , "custom" , & path_str] )
1512+ . await
1513+ . is_ok ( ) ;
1514+ cx. config
1515+ . expect ( [ "rustup" , "default" , "custom" ] )
1516+ . await
1517+ . is_ok ( ) ;
1518+ // Remove the executable bit so that spawn() fails with a permission error.
1519+ let rustc_path = path. join ( format ! ( "bin/rustc{EXE_SUFFIX}" ) ) ;
1520+ let mut perms = fs:: metadata ( & rustc_path) . unwrap ( ) . permissions ( ) ;
1521+ perms. set_mode ( 0o644 ) ;
1522+ fs:: set_permissions ( & rustc_path, perms) . unwrap ( ) ;
1523+ cx. config
1524+ . expect ( [ "rustup" , "show" , "active-toolchain" , "--verbose" ] )
1525+ . await
1526+ . extend_redactions ( [ ( "[RUSTUP_DIR]" , & cx. config . rustupdir . to_string ( ) ) ] )
1527+ . with_stdout ( snapbox:: str![ [ r#"
1528+ custom
1529+ active because: it's the default toolchain
1530+ compiler: (error reading rustc version: Permission denied [..])
1531+ path: [RUSTUP_DIR]/toolchains/custom
1532+
1533+ "# ] ] )
1534+ . with_stderr ( snapbox:: str![ [ "" ] ] )
1535+ . is_ok ( ) ;
1536+ }
1537+
15021538#[ tokio:: test]
15031539async fn show_active_toolchain_with_verbose ( ) {
15041540 let cx = CliTestContext :: new ( Scenario :: SimpleV2 ) . await ;
0 commit comments