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

mv: gnu test case mv-n compatibility (#6599)

* uucore: add update control `none-fail`

* uucore: show suggestion when parse errors occurs because of an ambiguous value

* added tests for fail-none and ambiguous parse error

* uucore: ambiguous value code refractor

* cp: no-clobber fail silently and outputs skipped message in debug

* mv: add --debug support

* minor changes

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
sreehari prasad 2024-09-14 12:41:17 +05:30 committed by GitHub
parent db402875f6
commit 8a9fb84a8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 147 additions and 63 deletions

View file

@ -324,18 +324,25 @@ fn test_cp_arg_update_interactive_error() {
#[test]
fn test_cp_arg_update_none() {
for argument in ["--update=none", "--update=non", "--update=n"] {
let (at, mut ucmd) = at_and_ucmd!();
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--update=none")
.succeeds()
.no_stderr()
.no_stdout();
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg(argument)
.succeeds()
.no_stderr()
.no_stdout();
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
#[test]
fn test_cp_arg_update_none_fail() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--update=none-fail")
.fails()
.stderr_contains(format!("not replacing '{}'", TEST_HOW_ARE_YOU_SOURCE));
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
#[test]
@ -588,10 +595,9 @@ fn test_cp_arg_interactive_verbose_clobber() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("a");
at.touch("b");
ucmd.args(&["-vin", "a", "b"])
.fails()
.stderr_is("cp: not replacing 'b'\n")
.no_stdout();
ucmd.args(&["-vin", "--debug", "a", "b"])
.succeeds()
.stdout_contains("skipped 'b'");
}
#[test]
@ -690,8 +696,9 @@ fn test_cp_arg_no_clobber() {
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--no-clobber")
.fails()
.stderr_contains("not replacing");
.arg("--debug")
.succeeds()
.stdout_contains("skipped 'how_are_you.txt'");
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
@ -702,7 +709,9 @@ fn test_cp_arg_no_clobber_inferred_arg() {
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--no-clob")
.fails();
.arg("--debug")
.succeeds()
.stdout_contains("skipped 'how_are_you.txt'");
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
@ -718,6 +727,7 @@ fn test_cp_arg_no_clobber_twice() {
.arg("--no-clobber")
.arg("source.txt")
.arg("dest.txt")
.arg("--debug")
.succeeds()
.no_stderr();
@ -729,7 +739,9 @@ fn test_cp_arg_no_clobber_twice() {
.arg("--no-clobber")
.arg("source.txt")
.arg("dest.txt")
.fails();
.arg("--debug")
.succeeds()
.stdout_contains("skipped 'dest.txt'");
assert_eq!(at.read("source.txt"), "some-content");
// Should be empty as the "no-clobber" should keep
@ -1773,11 +1785,12 @@ fn test_cp_preserve_links_case_7() {
ucmd.arg("-n")
.arg("--preserve=links")
.arg("--debug")
.arg("src/f")
.arg("src/g")
.arg("dest")
.fails()
.stderr_contains("not replacing");
.succeeds()
.stdout_contains("skipped");
assert!(at.dir_exists("dest"));
assert!(at.plus("dest").join("f").exists());