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

ls: fix flaky test (#2969)

This commit is contained in:
Terts Diepraam 2022-01-30 17:45:01 +01:00
parent ff4ac206f5
commit e01e2141f5

View file

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