Skip to content

Commit 44ec134

Browse files
committed
test(show): rustc permission denied
1 parent f7f0e7d commit 44ec134

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/suite/cli_rustup.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,39 @@ installed targets:
14981498
.is_ok();
14991499
}
15001500

1501+
#[cfg(unix)]
1502+
#[tokio::test]
1503+
async fn show_active_toolchain_rustc_permission_denied() {
1504+
use std::os::unix::fs::PermissionsExt;
1505+
1506+
let cx = CliTestContext::new(Scenario::SimpleV2).await;
1507+
let path = cx.config.customdir.join("custom-1");
1508+
let path_str = path.to_string_lossy();
1509+
cx.config
1510+
.expect(["rustup", "toolchain", "link", "custom", &path_str])
1511+
.await
1512+
.is_ok();
1513+
cx.config
1514+
.expect(["rustup", "default", "custom"])
1515+
.await
1516+
.is_ok();
1517+
// Remove the executable bit so that spawn() fails with a permission error.
1518+
let rustc_path = path.join(format!("bin/rustc{EXE_SUFFIX}"));
1519+
let mut perms = fs::metadata(&rustc_path).unwrap().permissions();
1520+
perms.set_mode(0o644);
1521+
fs::set_permissions(&rustc_path, perms).unwrap();
1522+
cx.config
1523+
.expect(["rustup", "show", "active-toolchain", "--verbose"])
1524+
.await
1525+
.with_stdout(snapbox::str![[r#"
1526+
...
1527+
compiler: (error reading rustc version: Permission denied [..])
1528+
...
1529+
"#]])
1530+
.with_stderr(snapbox::str![[""]])
1531+
.is_ok();
1532+
}
1533+
15011534
#[tokio::test]
15021535
async fn show_active_toolchain_with_verbose() {
15031536
let cx = CliTestContext::new(Scenario::SimpleV2).await;

0 commit comments

Comments
 (0)