mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
cp: refuse to copy symlink over itself
This commit is contained in:
parent
d957e64999
commit
e92e419a93
2 changed files with 32 additions and 1 deletions
|
@ -5218,6 +5218,31 @@ mod same_file {
|
|||
assert_eq!(symlink1, at.resolve_link(symlink2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_same_symlink_to_itself_no_dereference() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.write(FILE_NAME, CONTENTS);
|
||||
at.symlink_file(FILE_NAME, SYMLINK_NAME);
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-P", SYMLINK_NAME, SYMLINK_NAME])
|
||||
.fails()
|
||||
.stderr_contains("are the same file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_same_dangling_symlink_to_itself_no_dereference() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.symlink_file("nonexistent_file", SYMLINK_NAME);
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-P", SYMLINK_NAME, SYMLINK_NAME])
|
||||
.fails()
|
||||
.stderr_contains("are the same file");
|
||||
}
|
||||
|
||||
// the following tests tries to copy file to a hardlink of the same file with
|
||||
// various options
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue