Skip to content

Commit

Permalink
cp: fix test cases to use update option
Browse files Browse the repository at this point in the history
  • Loading branch information
aimerlief committed Feb 10, 2025
1 parent 16c61e2 commit d5955a6
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6043,17 +6043,35 @@ fn test_cp_from_stdin() {
}

#[test]
fn test_cp_verbose_message_after_interactive_prompt() {
fn test_cp_update_older_interactive_prompt_yes() {
let (at, mut ucmd) = at_and_ucmd!();
let src_file = "a";
let dst_file = "b";
let old_file = "old";
let new_file = "new";

at.touch(src_file);
at.touch(dst_file);
let f = at.make_file(old_file);
f.set_modified(std::time::UNIX_EPOCH).unwrap();
at.touch(new_file);

ucmd.args(&["-i", "--verbose", src_file, dst_file])
ucmd.args(&["-i", "-v", "--update=older", new_file, old_file])
.pipe_in("Y\n")
.stderr_to_stdout()
.succeeds()
.stdout_is("cp: overwrite 'b'? 'a' -> 'b'\n");
.stdout_is("cp: overwrite 'old'? 'new' -> 'old'\n");
}

#[test]
fn test_cp_update_older_interactive_prompt_no() {
let (at, mut ucmd) = at_and_ucmd!();
let old_file = "old";
let new_file = "new";

let f = at.make_file(old_file);
f.set_modified(std::time::UNIX_EPOCH).unwrap();
at.touch(new_file);

ucmd.args(&["-i", "-v", "--update=older", new_file, old_file])
.pipe_in("N\n")
.stderr_to_stdout()
.fails()
.stdout_is("cp: overwrite 'old'? ");
}

0 comments on commit d5955a6

Please # to comment.