mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
test: fix wsl executable permission
This commit is contained in:
parent
57dc11e586
commit
96d3a95a39
1 changed files with 21 additions and 1 deletions
|
@ -440,7 +440,27 @@ fn test_file_is_not_writable() {
|
|||
|
||||
#[test]
|
||||
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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue