1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

cp: disabled verbose output if file has been skipped

This commit is contained in:
Thomas Kilian 2025-02-24 22:24:27 +01:00
parent b3f7aca846
commit 63fe4fb327
2 changed files with 62 additions and 6 deletions

View file

@ -439,6 +439,29 @@ fn test_cp_arg_update_older_dest_not_older_than_src() {
assert_eq!(at.read(new), "new content\n");
}
#[test]
fn test_cp_arg_update_older_dest_not_older_than_src_no_verbose_output() {
let (at, mut ucmd) = at_and_ucmd!();
let old = "test_cp_arg_update_dest_not_older_file1";
let new = "test_cp_arg_update_dest_not_older_file2";
let old_content = "old content\n";
let new_content = "new content\n";
at.write(old, old_content);
at.write(new, new_content);
ucmd.arg(old)
.arg(new)
.arg("--verbose")
.arg("--update=older")
.succeeds()
.no_stderr()
.no_stdout();
assert_eq!(at.read(new), "new content\n");
}
#[test]
fn test_cp_arg_update_older_dest_older_than_src() {
let (at, mut ucmd) = at_and_ucmd!();
@ -464,6 +487,32 @@ fn test_cp_arg_update_older_dest_older_than_src() {
assert_eq!(at.read(old), "new content\n");
}
#[test]
fn test_cp_arg_update_older_dest_older_than_src_with_verbose_output() {
let (at, mut ucmd) = at_and_ucmd!();
let old = "test_cp_arg_update_dest_older_file1";
let new = "test_cp_arg_update_dest_older_file2";
let old_content = "old content\n";
let new_content = "new content\n";
let mut f = at.make_file(old);
f.write_all(old_content.as_bytes()).unwrap();
f.set_modified(std::time::UNIX_EPOCH).unwrap();
at.write(new, new_content);
ucmd.arg(new)
.arg(old)
.arg("--verbose")
.arg("--update=older")
.succeeds()
.no_stderr()
.stdout_is(format!("'{new}' -> '{old}'\n"));
assert_eq!(at.read(old), "new content\n");
}
#[test]
fn test_cp_arg_update_short_no_overwrite() {
// same as --update=older