mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
fix: address test failures
This commit is contained in:
parent
f2f2f7033e
commit
be49eb68f3
2 changed files with 11 additions and 4 deletions
|
@ -11,6 +11,8 @@ extern crate libc;
|
|||
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use nix::errno::Errno;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use nix::fcntl::{open, OFlag};
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use nix::sys::stat::Mode;
|
||||
|
@ -170,9 +172,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
// Use the Nix open to be able to set the NONBLOCK flags for fifo files
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
{
|
||||
open(Path::new(&f), OFlag::O_NONBLOCK, Mode::empty())
|
||||
.map_err_context(|| format!("cannot stat {}", f.quote()))?;
|
||||
let path = Path::new(&f);
|
||||
if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) {
|
||||
if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) {
|
||||
return e.map_err_context(|| format!("cannot stat {}", f.quote()))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
{
|
||||
if !Path::new(&f).exists() {
|
||||
|
|
|
@ -64,9 +64,9 @@ fn test_sync_no_permission_dir() {
|
|||
|
||||
ts.ccmd("chmod").arg("0").arg(dir).succeeds();
|
||||
let result = ts.ucmd().arg("--data").arg(dir).fails();
|
||||
result.stderr_contains("sync: error opening 'foo': Permission denied");
|
||||
result.stderr_contains("sync: cannot stat 'foo': Permission denied");
|
||||
let result = ts.ucmd().arg(dir).fails();
|
||||
result.stderr_contains("sync: error opening 'foo': Permission denied");
|
||||
result.stderr_contains("sync: cannot stat 'foo': Permission denied");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
|
Loading…
Reference in a new issue