66// spell-checker:ignore mydir
77use crate :: common:: util:: TestScenario ;
88use filetime:: FileTime ;
9- use std:: thread:: sleep;
10- use std:: time:: Duration ;
9+ use std:: io:: Write ;
1110
1211#[ test]
1312fn test_mv_invalid_arg ( ) {
@@ -974,9 +973,9 @@ fn test_mv_arg_update_older_dest_not_older() {
974973 let old_content = "file1 content\n " ;
975974 let new_content = "file2 content\n " ;
976975
977- at. write ( old, old_content ) ;
978-
979- sleep ( Duration :: from_secs ( 1 ) ) ;
976+ let mut f = at. make_file ( old) ;
977+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
978+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
980979
981980 at. write ( new, new_content) ;
982981
@@ -1001,9 +1000,9 @@ fn test_mv_arg_update_none_then_all() {
10011000 let old_content = "old content\n " ;
10021001 let new_content = "new content\n " ;
10031002
1004- at. write ( old, old_content ) ;
1005-
1006- sleep ( Duration :: from_secs ( 1 ) ) ;
1003+ let mut f = at. make_file ( old) ;
1004+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
1005+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
10071006
10081007 at. write ( new, new_content) ;
10091008
@@ -1029,9 +1028,9 @@ fn test_mv_arg_update_all_then_none() {
10291028 let old_content = "old content\n " ;
10301029 let new_content = "new content\n " ;
10311030
1032- at. write ( old, old_content ) ;
1033-
1034- sleep ( Duration :: from_secs ( 1 ) ) ;
1031+ let mut f = at. make_file ( old) ;
1032+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
1033+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
10351034
10361035 at. write ( new, new_content) ;
10371036
@@ -1055,9 +1054,9 @@ fn test_mv_arg_update_older_dest_older() {
10551054 let old_content = "file1 content\n " ;
10561055 let new_content = "file2 content\n " ;
10571056
1058- at. write ( old, old_content ) ;
1059-
1060- sleep ( Duration :: from_secs ( 1 ) ) ;
1057+ let mut f = at. make_file ( old) ;
1058+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
1059+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
10611060
10621061 at. write ( new, new_content) ;
10631062
@@ -1081,9 +1080,9 @@ fn test_mv_arg_update_short_overwrite() {
10811080 let old_content = "file1 content\n " ;
10821081 let new_content = "file2 content\n " ;
10831082
1084- at. write ( old, old_content ) ;
1085-
1086- sleep ( Duration :: from_secs ( 1 ) ) ;
1083+ let mut f = at. make_file ( old) ;
1084+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
1085+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
10871086
10881087 at. write ( new, new_content) ;
10891088
@@ -1107,9 +1106,9 @@ fn test_mv_arg_update_short_no_overwrite() {
11071106 let old_content = "file1 content\n " ;
11081107 let new_content = "file2 content\n " ;
11091108
1110- at. write ( old, old_content ) ;
1111-
1112- sleep ( Duration :: from_secs ( 1 ) ) ;
1109+ let mut f = at. make_file ( old) ;
1110+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
1111+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
11131112
11141113 at. write ( new, new_content) ;
11151114
0 commit comments