mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #2965 from tertsdiepraam/test-wsl-exec-permission
`test`: fix wsl executable permission
This commit is contained in:
commit
bc3f540a1b
1 changed files with 21 additions and 1 deletions
|
@ -440,7 +440,27 @@ fn test_file_is_not_writable() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_file_is_not_executable() {
|
fn test_file_is_not_executable() {
|
||||||
new_ucmd!().args(&["!", "-x", "regular_file"]).succeeds();
|
#[cfg(unix)]
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
let (_, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
|
// WSL creates executable files by default, so if we are on unix, make sure
|
||||||
|
// to set make it non-executable.
|
||||||
|
// Files on other targets are non-executable by default.
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
let metadata = std::fs::metadata(at.plus("regular_file")).unwrap();
|
||||||
|
let mut permissions = metadata.permissions();
|
||||||
|
|
||||||
|
// The conversion is useless on some platforms and casts from u16 to
|
||||||
|
// u32 on others
|
||||||
|
#[allow(clippy::useless_conversion)]
|
||||||
|
permissions.set_mode(permissions.mode() & !u32::from(libc::S_IXUSR));
|
||||||
|
std::fs::set_permissions(at.plus("regular_file"), permissions).unwrap();
|
||||||
|
}
|
||||||
|
ucmd.args(&["!", "-x", "regular_file"]).succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue