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

test: remove sleep from tests

This commit is contained in:
Daniel Hofstetter 2025-02-20 10:48:01 +01:00
parent a2af5d60b5
commit 1910da5869

View file

@ -6,7 +6,6 @@
// spell-checker:ignore (words) egid euid pseudofloat // spell-checker:ignore (words) egid euid pseudofloat
use crate::common::util::TestScenario; use crate::common::util::TestScenario;
use std::thread::sleep;
#[test] #[test]
fn test_empty_test_equivalent_to_false() { fn test_empty_test_equivalent_to_false() {
@ -380,28 +379,28 @@ fn test_same_device_inode() {
fn test_newer_file() { fn test_newer_file() {
let scenario = TestScenario::new(util_name!()); let scenario = TestScenario::new(util_name!());
scenario.fixtures.touch("regular_file"); let older_file = scenario.fixtures.make_file("older_file");
sleep(std::time::Duration::from_millis(100)); older_file.set_modified(std::time::UNIX_EPOCH).unwrap();
scenario.fixtures.touch("newer_file"); scenario.fixtures.touch("newer_file");
scenario scenario
.ucmd() .ucmd()
.args(&["newer_file", "-nt", "regular_file"]) .args(&["newer_file", "-nt", "older_file"])
.succeeds(); .succeeds();
scenario scenario
.ucmd() .ucmd()
.args(&["regular_file", "-nt", "newer_file"]) .args(&["older_file", "-nt", "newer_file"])
.fails(); .fails();
scenario scenario
.ucmd() .ucmd()
.args(&["regular_file", "-ot", "newer_file"]) .args(&["older_file", "-ot", "newer_file"])
.succeeds(); .succeeds();
scenario scenario
.ucmd() .ucmd()
.args(&["newer_file", "-ot", "regular_file"]) .args(&["newer_file", "-ot", "older_file"])
.fails(); .fails();
} }
@ -946,12 +945,15 @@ fn test_bracket_syntax_version() {
fn test_file_N() { fn test_file_N() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
scene.ucmd().args(&["-N", "regular_file"]).fails();
let f = at.make_file("file");
f.set_modified(std::time::UNIX_EPOCH).unwrap();
scene.ucmd().args(&["-N", "file"]).fails();
// The file will have different create/modified data // The file will have different create/modified data
// so, test -N will return 0 // so, test -N will return 0
sleep(std::time::Duration::from_millis(100)); at.touch("file");
at.touch("regular_file"); scene.ucmd().args(&["-N", "file"]).succeeds();
scene.ucmd().args(&["-N", "regular_file"]).succeeds();
} }
#[test] #[test]