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

mv: Fix stderr output mv file into dir and dir into file where both are files (#5464)

* Add tests mv file into dir and dir into file where both are files

* Fix test_mv_dir_into_file_where_both_are_files

* Fix test_mv_file_into_dir_where_both_are_files

* Store String in error instead of PathBuf

* Implement path_ends_with_terminator for windows

* Fix compilation on windows
This commit is contained in:
Mick van Gelderen 2023-10-28 15:04:51 +02:00 committed by GitHub
parent 5dbbdb4788
commit 5c100dd088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 2 deletions

View file

@ -1414,6 +1414,35 @@ fn test_mv_directory_into_subdirectory_of_itself_fails() {
"mv: cannot move 'mydir/' to a subdirectory of itself, 'mydir/mydir_2/mydir/'",
);
}
#[test]
fn test_mv_file_into_dir_where_both_are_files() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("a");
at.touch("b");
scene
.ucmd()
.arg("a")
.arg("b/")
.fails()
.stderr_contains("mv: failed to access 'b/': Not a directory");
}
#[test]
fn test_mv_dir_into_file_where_both_are_files() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("a");
at.touch("b");
scene
.ucmd()
.arg("a/")
.arg("b")
.fails()
.stderr_contains("mv: cannot stat 'a/': Not a directory");
}
// Todo:
// $ at.touch a b