@@ -8,6 +8,7 @@ use crate::common::util::TestScenario;
8
8
#[ cfg( not( windows) ) ]
9
9
use std:: fs:: set_permissions;
10
10
11
+ use std:: io:: Write ;
11
12
#[ cfg( not( windows) ) ]
12
13
use std:: os:: unix:: fs;
13
14
@@ -447,9 +448,9 @@ fn test_cp_arg_update_older_dest_older_than_src() {
447
448
let old_content = "old content\n " ;
448
449
let new_content = "new content\n " ;
449
450
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 ( ) ;
453
454
454
455
at. write ( new, new_content) ;
455
456
@@ -473,9 +474,9 @@ fn test_cp_arg_update_short_no_overwrite() {
473
474
let old_content = "old content\n " ;
474
475
let new_content = "new content\n " ;
475
476
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 ( ) ;
479
480
480
481
at. write ( new, new_content) ;
481
482
@@ -499,9 +500,9 @@ fn test_cp_arg_update_short_overwrite() {
499
500
let old_content = "old content\n " ;
500
501
let new_content = "new content\n " ;
501
502
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 ( ) ;
505
506
506
507
at. write ( new, new_content) ;
507
508
@@ -526,9 +527,9 @@ fn test_cp_arg_update_none_then_all() {
526
527
let old_content = "old content\n " ;
527
528
let new_content = "new content\n " ;
528
529
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 ( ) ;
532
533
533
534
at. write ( new, new_content) ;
534
535
@@ -554,9 +555,9 @@ fn test_cp_arg_update_all_then_none() {
554
555
let old_content = "old content\n " ;
555
556
let new_content = "new content\n " ;
556
557
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 ( ) ;
560
561
561
562
at. write ( new, new_content) ;
562
563
0 commit comments