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

bug(cp): like gnu/cp, don't show any message when --no-clobber is used

Simple example:
touch bar
rm -rf /tmp/foo
mkdir -p /tmp/foo
cp -pnL -v bar /tmp/foo
echo $?
cp -pnL -v bar /tmp/foo
echo $?

rm -rf /tmp/foo
mkdir -p /tmp/foo
./target/debug/coreutils cp -pnL -v bar /tmp/foo
echo $?
./target/debug/coreutils cp -pnL bar /tmp/foo
echo $?
This commit is contained in:
Sylvestre Ledru 2020-12-16 23:52:42 +01:00
parent 1e9820a7c4
commit 5a62dcafaa
2 changed files with 45 additions and 9 deletions

View file

@ -255,7 +255,40 @@ fn test_cp_arg_no_clobber() {
assert!(result.success);
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
assert!(result.stderr.contains("Not overwriting"));
}
#[test]
fn test_cp_arg_no_clobber_twice() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("source.txt");
let result = scene
.ucmd()
.arg("--no-clobber")
.arg("source.txt")
.arg("dest.txt")
.run();
println!("stderr = {:?}", result.stderr);
println!("stdout = {:?}", result.stdout);
assert!(result.success);
assert!(result.stderr.is_empty());
assert_eq!(at.read("source.txt"), "");
at.append("source.txt", "some-content");
let result = scene
.ucmd()
.arg("--no-clobber")
.arg("source.txt")
.arg("dest.txt")
.run();
assert!(result.success);
assert_eq!(at.read("source.txt"), "some-content");
// Should be empty as the "no-clobber" should keep
// the previous version
assert_eq!(at.read("dest.txt"), "");
assert!(!result.stderr.contains("Not overwriting"));
}
#[test]