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

Merge pull request #4831 from sylvestre/mv-hardlink

mv: 'mv source hardlink' should fail
This commit is contained in:
Daniel Hofstetter 2023-05-08 16:12:23 +02:00 committed by GitHub
commit d769871374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 185 additions and 81 deletions

View file

@ -400,6 +400,39 @@ fn test_mv_same_file() {
.stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n",));
}
#[test]
#[cfg(all(unix, not(target_os = "android")))]
fn test_mv_same_hardlink() {
let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_mv_same_file_a";
let file_b = "test_mv_same_file_b";
at.touch(file_a);
at.hard_link(file_a, file_b);
at.touch(file_a);
ucmd.arg(file_a)
.arg(file_b)
.fails()
.stderr_is(format!("mv: '{file_a}' and '{file_b}' are the same file\n",));
}
#[test]
#[cfg(all(unix, not(target_os = "android")))]
fn test_mv_same_hardlink_backup_simple() {
let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_mv_same_file_a";
let file_b = "test_mv_same_file_b";
at.touch(file_a);
at.hard_link(file_a, file_b);
ucmd.arg(file_a)
.arg(file_b)
.arg("--backup=simple")
.succeeds();
}
#[test]
fn test_mv_same_file_not_dot_dir() {
let (at, mut ucmd) = at_and_ucmd!();