mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: fix backup of destination symlink
This commit is contained in:
parent
bf26eda786
commit
0701f535ac
2 changed files with 26 additions and 1 deletions
|
@ -678,6 +678,27 @@ fn test_cp_arg_backup() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_arg_backup_with_dest_a_symlink() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let source = "source";
|
||||
let source_content = "content";
|
||||
let symlink = "symlink";
|
||||
let original = "original";
|
||||
let backup = "symlink~";
|
||||
|
||||
at.write(source, source_content);
|
||||
at.write(original, "original");
|
||||
at.symlink_file(original, symlink);
|
||||
|
||||
ucmd.arg("-b").arg(source).arg(symlink).succeeds();
|
||||
|
||||
assert!(!at.symlink_exists(symlink));
|
||||
assert_eq!(source_content, at.read(symlink));
|
||||
assert!(at.symlink_exists(backup));
|
||||
assert_eq!(original, at.resolve_link(backup));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_arg_backup_with_other_args() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue