Skip to content

Commit

Permalink
Merge pull request #6890 from cakebaker/cp_remove_sleep_in_tests
Browse files Browse the repository at this point in the history
cp: remove some `sleep()` calls in tests
  • Loading branch information
sylvestre authored Nov 26, 2024
2 parents cae71a8 + c8b0c8b commit 906a633
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::common::util::TestScenario;
#[cfg(not(windows))]
use std::fs::set_permissions;

use std::io::Write;
#[cfg(not(windows))]
use std::os::unix::fs;

Expand Down Expand Up @@ -447,9 +448,9 @@ fn test_cp_arg_update_older_dest_older_than_src() {
let old_content = "old content\n";
let new_content = "new content\n";

at.write(old, old_content);

sleep(Duration::from_secs(1));
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();

at.write(new, new_content);

Expand All @@ -473,9 +474,9 @@ fn test_cp_arg_update_short_no_overwrite() {
let old_content = "old content\n";
let new_content = "new content\n";

at.write(old, old_content);

sleep(Duration::from_secs(1));
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();

at.write(new, new_content);

Expand All @@ -499,9 +500,9 @@ fn test_cp_arg_update_short_overwrite() {
let old_content = "old content\n";
let new_content = "new content\n";

at.write(old, old_content);

sleep(Duration::from_secs(1));
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();

at.write(new, new_content);

Expand All @@ -526,9 +527,9 @@ fn test_cp_arg_update_none_then_all() {
let old_content = "old content\n";
let new_content = "new content\n";

at.write(old, old_content);

sleep(Duration::from_secs(1));
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();

at.write(new, new_content);

Expand All @@ -554,9 +555,9 @@ fn test_cp_arg_update_all_then_none() {
let old_content = "old content\n";
let new_content = "new content\n";

at.write(old, old_content);

sleep(Duration::from_secs(1));
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();

at.write(new, new_content);

Expand Down

0 comments on commit 906a633

Please sign in to comment.