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

Fix mv bug: Should be able to stat files, but not able to mv if source and target are the same (#2763)

Closes #2760
This commit is contained in:
electricboogie 2021-12-12 10:49:38 -06:00 committed by GitHub
parent 3df989eacf
commit c7f7a222b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 28 deletions

View file

@ -232,6 +232,40 @@ fn test_mv_force_replace_file() {
assert!(at.file_exists(file_b));
}
#[test]
fn test_mv_same_file() {
let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_mv_same_file_a";
at.touch(file_a);
ucmd.arg(file_a).arg(file_a).fails().stderr_is(format!(
"mv: '{f}' and '{f}' are the same file\n",
f = file_a,
));
}
#[test]
fn test_mv_same_file_not_dot_dir() {
let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_mv_errors_dir";
at.mkdir(dir);
ucmd.arg(dir).arg(dir).fails().stderr_is(format!(
"mv: cannot move '{d}' to a subdirectory of itself, '{d}/{d}'",
d = dir,
));
}
#[test]
fn test_mv_same_file_dot_dir() {
let (_at, mut ucmd) = at_and_ucmd!();
ucmd.arg(".")
.arg(".")
.fails()
.stderr_is("mv: '.' and '.' are the same file\n".to_string());
}
#[test]
fn test_mv_simple_backup() {
let (at, mut ucmd) = at_and_ucmd!();