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

ln: implement fixes for tests/ln/backup-1.sh

When doing
ln b b~
ln -f --b=simple a b

First, we create a backup of b
Then, we force the override of a => b but we make sure that the backup is
done.

So, we had a bug in the ordering of the actions.
we were first removing b. Therefore, losing the capability to do a backup of this.
This commit is contained in:
Sylvestre Ledru 2022-03-31 00:27:59 +02:00
parent e553241750
commit 676283ce93
2 changed files with 42 additions and 12 deletions

View file

@ -624,3 +624,29 @@ fn test_backup_same_file() {
.fails()
.stderr_contains("'file1' and './file1' are the same file");
}
#[test]
fn test_backup_force() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.write("a", "a\n");
at.write("b", "b2\n");
scene.ucmd().args(&["-s", "b", "b~"]).succeeds().no_stderr();
assert!(at.file_exists("a"));
assert!(at.file_exists("b"));
assert!(at.file_exists("b~"));
scene
.ucmd()
.args(&["-f", "--b=simple", "a", "b"])
.succeeds()
.no_stderr();
assert!(at.file_exists("a"));
assert!(at.file_exists("b"));
assert!(at.file_exists("b~"));
assert_eq!(at.read("a"), "a\n");
assert_eq!(at.read("b"), "a\n");
// we should have the same content as b as we had time to do a backup
assert_eq!(at.read("b~"), "b2\n");
}