Skip to content

Commit 9b1f458

Browse files
Alonely0sylvestre
authored andcommitted
chore: add test coverage for latest cp bug fix
1 parent 751ddfb commit 9b1f458

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

tests/by-util/test_cp.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7090,3 +7090,49 @@ fn test_cp_recursive_files_ending_in_backslash() {
70907090
ts.ucmd().args(&["-r", "a", "b"]).succeeds();
70917091
assert!(at.file_exists("b/foo\\"));
70927092
}
7093+
7094+
#[test]
7095+
fn test_cp_no_preserve_target_directory() {
7096+
/* Expected result:
7097+
├── a
7098+
│ └── b
7099+
│ └── c
7100+
│ └── d
7101+
│ └── f1
7102+
├── d
7103+
│ └── f1
7104+
└── e
7105+
├── b
7106+
│ └── c
7107+
│ └── d
7108+
│ ├── c
7109+
│ │ └── d
7110+
│ │ └── f1
7111+
│ └── f1
7112+
├── d
7113+
│ └── f1
7114+
├── f2
7115+
└── f3
7116+
*/
7117+
7118+
let ts = TestScenario::new(util_name!());
7119+
let at = &ts.fixtures;
7120+
at.mkdir_all("a/b/c/d");
7121+
at.touch("a/b/c/d/f1");
7122+
ts.ucmd().args(&["-rT", "a", "e"]).succeeds();
7123+
at.touch("e/f2");
7124+
ts.ucmd().args(&["-rT", "a/", "e/"]).succeeds();
7125+
at.touch("e/f3");
7126+
ts.ucmd().args(&["-rvT", "a/b/c", "e/"]).succeeds();
7127+
ts.ucmd().args(&["-rvT", "a/b/", "e/b/c/d/"]).succeeds();
7128+
ts.ucmd().args(&["-rT", "a/b/c", "."]).succeeds();
7129+
assert!(!at.dir_exists("e/a"));
7130+
assert!(at.file_exists("e/b/c/d/f1"));
7131+
assert!(at.file_exists("e/b/c/d/c/d/f1"));
7132+
assert!(!at.dir_exists("e/c"));
7133+
assert!(!at.dir_exists("e/c/d/b"));
7134+
assert!(at.file_exists("e/d/f1"));
7135+
assert!(at.file_exists("./d/f1"));
7136+
assert!(at.file_exists("e/f2"));
7137+
assert!(at.file_exists("e/f3"));
7138+
}

0 commit comments

Comments
 (0)