From 9f07bf880944e777b218b43e435e9f8f03eab159 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 28 Mar 2024 16:02:54 +0100 Subject: [PATCH] mv: remove "sleep" in tests --- tests/by-util/test_mv.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 6f2693a86..6ab989ee4 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -6,8 +6,7 @@ // spell-checker:ignore mydir use crate::common::util::TestScenario; use filetime::FileTime; -use std::thread::sleep; -use std::time::Duration; +use std::io::Write; #[test] fn test_mv_invalid_arg() { @@ -974,9 +973,9 @@ fn test_mv_arg_update_older_dest_not_older() { let old_content = "file1 content\n"; let new_content = "file2 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); @@ -1001,9 +1000,9 @@ fn test_mv_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); @@ -1029,9 +1028,9 @@ fn test_mv_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); @@ -1055,9 +1054,9 @@ fn test_mv_arg_update_older_dest_older() { let old_content = "file1 content\n"; let new_content = "file2 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); @@ -1081,9 +1080,9 @@ fn test_mv_arg_update_short_overwrite() { let old_content = "file1 content\n"; let new_content = "file2 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); @@ -1107,9 +1106,9 @@ fn test_mv_arg_update_short_no_overwrite() { let old_content = "file1 content\n"; let new_content = "file2 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);