1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #2970 from tertsdiepraam/ls-fix-flaky-test

`ls`: fix flaky test
This commit is contained in:
Sylvestre Ledru 2022-01-31 14:26:40 +01:00 committed by GitHub
commit 829e4fcb2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,20 +7,17 @@ use crate::common::util::*;
extern crate regex;
use self::regex::Regex;
#[cfg(unix)]
#[cfg(all(unix, feature = "chmod"))]
use nix::unistd::{close, dup2};
#[cfg(unix)]
use std::os::unix::io::AsRawFd;
use std::collections::HashMap;
#[cfg(all(unix, feature = "chmod"))]
use std::os::unix::io::AsRawFd;
use std::path::Path;
use std::thread::sleep;
use std::time::Duration;
#[cfg(not(windows))]
extern crate libc;
#[cfg(not(windows))]
use self::libc::umask;
#[cfg(not(windows))]
use std::path::PathBuf;
#[cfg(not(windows))]
use std::sync::Mutex;
@ -577,18 +574,6 @@ fn test_ls_commas() {
#[test]
fn test_ls_long() {
#[cfg(not(windows))]
let last;
#[cfg(not(windows))]
{
let _guard = UMASK_MUTEX.lock();
last = unsafe { umask(0) };
unsafe {
umask(0o002);
}
}
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch(&at.plus_as_string("test-long"));
@ -596,18 +581,11 @@ fn test_ls_long() {
for arg in LONG_ARGS {
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
#[cfg(not(windows))]
result.stdout_contains("-rw-rw-r--");
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
#[cfg(windows)]
result.stdout_contains("---------- 1 somebody somegroup");
}
#[cfg(not(windows))]
{
unsafe {
umask(last);
}
}
}
#[cfg(not(windows))]