mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
mv: manages the 'seen' file list before moving
Should help with tests/mv/childproof.sh
This commit is contained in:
parent
06c98fbdd3
commit
3af8ad0fe6
2 changed files with 43 additions and 0 deletions
|
@ -1469,6 +1469,32 @@ fn test_mv_file_into_dir_where_both_are_files() {
|
|||
.stderr_contains("mv: failed to access 'b/': Not a directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_seen_file() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.mkdir("a");
|
||||
at.mkdir("b");
|
||||
at.mkdir("c");
|
||||
at.write("a/f", "a");
|
||||
at.write("b/f", "b");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("a/f")
|
||||
.arg("b/f")
|
||||
.arg("c")
|
||||
.fails()
|
||||
.stderr_contains("will not overwrite just-created 'c/f' with 'b/f'");
|
||||
|
||||
// a/f has been moved into c/f
|
||||
assert!(at.plus("c").join("f").exists());
|
||||
// b/f still exists
|
||||
assert!(at.plus("b").join("f").exists());
|
||||
// a/f no longer exists
|
||||
assert!(!at.plus("a").join("f").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mv_dir_into_file_where_both_are_files() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue