8000 test: remove `sleep` from tests by cakebaker · Pull Request #7327 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: remove sleep from tests #7327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions tests/by-util/test_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// spell-checker:ignore (words) egid euid pseudofloat

use crate::common::util::TestScenario;
use std::thread::sleep;

#[test]
fn test_empty_test_equivalent_to_false() {
Expand Down Expand Up @@ -380,28 +379,28 @@ fn test_same_device_inode() {
fn test_newer_file() {
let scenario = TestScenario::new(util_name!());

scenario.fixtures.touch("regular_file");
sleep(std::time::Duration::from_millis(100));
let older_file = scenario.fixtures.make_file("older_file");
older_file.set_modified(std::time::UNIX_EPOCH).unwrap();
scenario.fixtures.touch("newer_file");

scenario
.ucmd()
.args(&["newer_file", "-nt", "regular_file"])
.args(&["newer_file", "-nt", "older_file"])
.succeeds();

scenario
.ucmd()
.args(&["regular_file", "-nt", "newer_file"])
.args(&["older_file", "-nt", "newer_file"])
.fails();

scenario
.ucmd()
.args(&["regular_file", "-ot", "newer_file"])
.args(&["older_file", "-ot", "newer_file"])
.succeeds();

scenario
.ucmd()
.args(&["newer_file", "-ot", "regular_file"])
.args(&["newer_file", "-ot", "older_file"])
.fails();
}

Expand Down Expand Up @@ -946,12 +945,15 @@ fn test_bracket_syntax_version() {
fn test_file_N() {
let scene = TestScenario::new(util_name!());
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
// so, test -N will return 0
sleep(std::time::Duration::from_millis(100));
at.touch("regular_file");
scene.ucmd().args(&["-N", "regular_file"]).succeeds();
at.touch("file");
scene.ucmd().args(&["-N", "file"]).succeeds();
}

#[test]
Expand Down
Loading
0