Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliebenow committed Sep 16, 2024
1 parent 201e573 commit b601f9d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,41 @@ fn test_cp_arg_interactive_verbose_clobber() {
.stdout_contains("skipped 'b'");
}

#[test]
#[cfg(unix)]
fn test_cp_f_i_verbose_non_writeable_destination_y() {
let (at, mut ucmd) = at_and_ucmd!();

at.touch("a");
at.touch("b");

// Non-writeable file
at.set_mode("b", 0o0000);

ucmd.args(&["-f", "-i", "--verbose", "a", "b"])
.pipe_in("y")
.succeeds()
.stderr_is("cp: replace 'b', overriding mode 0000 (---------)? ")
.stdout_is("'a' -> 'b'\n");
}

#[test]
#[cfg(unix)]
fn test_cp_f_i_verbose_non_writeable_destination_empty() {
let (at, mut ucmd) = at_and_ucmd!();

at.touch("a");
at.touch("b");

// Non-writeable file
at.set_mode("b", 0o0000);

ucmd.args(&["-f", "-i", "--verbose", "a", "b"])
.pipe_in("")
.fails()
.stderr_only("cp: replace 'b', overriding mode 0000 (---------)? ");
}

#[test]
#[cfg(target_os = "linux")]
fn test_cp_arg_link() {
Expand Down

0 comments on commit b601f9d

Please sign in to comment.