fix: fixcd (#6799)

* fix: fixcd

try to fix

Log: try to fix the bug with can enter a permisson error fold

* change wording

* fat

* fmt

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
Access
2022-11-05 02:38:39 +08:00
committed by GitHub
parent bb968304da
commit b9195c2668
4 changed files with 140 additions and 5 deletions

View File

@ -289,3 +289,43 @@ fn test_change_windows_drive() {
.exists());
})
}
#[cfg(unix)]
#[test]
fn cd_permission_deined_folder() {
Playground::setup("cd_test_21", |dirs, sandbox| {
sandbox.mkdir("banned");
let actual = nu!(
cwd: dirs.test(),
r#"
chmod -x banned
cd banned
"#
);
assert!(actual.err.contains("Cannot change directory to"));
nu!(
cwd: dirs.test(),
r#"
chmod +x banned
rm banned
"#
);
});
}
// FIXME: cd_permission_deined_folder on windows
#[ignore]
#[cfg(windows)]
#[test]
fn cd_permission_deined_folder() {
Playground::setup("cd_test_21", |dirs, sandbox| {
sandbox.mkdir("banned");
let actual = nu!(
cwd: dirs.test(),
r#"
icacls banned /deny BUILTIN\Administrators:F
cd banned
"#
);
assert!(actual.err.contains("Folder is not able to read"));
});
}