@@ -8,6 +8,7 @@ use crate::common::util::TestScenario;
88#[ cfg( not( windows) ) ]
99use std:: fs:: set_permissions;
1010
11+ use std:: io:: Write ;
1112#[ cfg( not( windows) ) ]
1213use std:: os:: unix:: fs;
1314
@@ -447,9 +448,9 @@ fn test_cp_arg_update_older_dest_older_than_src() {
447448 let old_content = "old content\n " ;
448449 let new_content = "new content\n " ;
449450
450- at. write ( old, old_content ) ;
451-
452- sleep ( Duration :: from_secs ( 1 ) ) ;
451+ let mut f = at. make_file ( old) ;
452+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
453+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
453454
454455 at. write ( new, new_content) ;
455456
@@ -473,9 +474,9 @@ fn test_cp_arg_update_short_no_overwrite() {
473474 let old_content = "old content\n " ;
474475 let new_content = "new content\n " ;
475476
476- at. write ( old, old_content ) ;
477-
478- sleep ( Duration :: from_secs ( 1 ) ) ;
477+ let mut f = at. make_file ( old) ;
478+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
479+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
479480
480481 at. write ( new, new_content) ;
481482
@@ -499,9 +500,9 @@ fn test_cp_arg_update_short_overwrite() {
499500 let old_content = "old content\n " ;
500501 let new_content = "new content\n " ;
501502
502- at. write ( old, old_content ) ;
503-
504- sleep ( Duration :: from_secs ( 1 ) ) ;
503+ let mut f = at. make_file ( old) ;
504+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
505+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
505506
506507 at. write ( new, new_content) ;
507508
@@ -526,9 +527,9 @@ fn test_cp_arg_update_none_then_all() {
526527 let old_content = "old content\n " ;
527528 let new_content = "new content\n " ;
528529
529- at. write ( old, old_content ) ;
530-
531- sleep ( Duration :: from_secs ( 1 ) ) ;
530+ let mut f = at. make_file ( old) ;
531+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
532+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
532533
533534 at. write ( new, new_content) ;
534535
@@ -554,9 +555,9 @@ fn test_cp_arg_update_all_then_none() {
554555 let old_content = "old content\n " ;
555556 let new_content = "new content\n " ;
556557
557- at. write ( old, old_content ) ;
558-
559- sleep ( Duration :: from_secs ( 1 ) ) ;
558+ let mut f = at. make_file ( old) ;
559+ f . write_all ( old_content . as_bytes ( ) ) . unwrap ( ) ;
560+ f . set_modified ( std :: time :: UNIX_EPOCH ) . unwrap ( ) ;
560561
561562 at. write ( new, new_content) ;
562563
0 commit comments