Skip to content

Commit 906a633

Browse files
authored
Merge pull request #6890 from cakebaker/cp_remove_sleep_in_tests
cp: remove some `sleep()` calls in tests
2 parents cae71a8 + c8b0c8b commit 906a633

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

tests/by-util/test_cp.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::common::util::TestScenario;
88
#[cfg(not(windows))]
99
use std::fs::set_permissions;
1010

11+
use std::io::Write;
1112
#[cfg(not(windows))]
1213
use 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

Comments
 (0)