mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[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};
|
use nix::fcntl::{open, OFlag};
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
use nix::sys::stat::Mode;
|
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
|
// Use the Nix open to be able to set the NONBLOCK flags for fifo files
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
{
|
{
|
||||||
open(Path::new(&f), OFlag::O_NONBLOCK, Mode::empty())
|
let path = Path::new(&f);
|
||||||
.map_err_context(|| format!("cannot stat {}", f.quote()))?;
|
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")))]
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
{
|
{
|
||||||
if !Path::new(&f).exists() {
|
if !Path::new(&f).exists() {
|
||||||
|
|
|
@ -64,9 +64,9 @@ fn test_sync_no_permission_dir() {
|
||||||
|
|
||||||
ts.ccmd("chmod").arg("0").arg(dir).succeeds();
|
ts.ccmd("chmod").arg("0").arg(dir).succeeds();
|
||||||
let result = ts.ucmd().arg("--data").arg(dir).fails();
|
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();
|
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"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue