mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
rm: fix the usage of '/..' '/.' with -rf options
fix the test tests/rm/r-4 --------- Co-authored-by: Julian Beltz <MJayBeltz@gmail.com> Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
parent
8a481ccf1c
commit
a16630fded
3 changed files with 148 additions and 4 deletions
|
@ -677,6 +677,68 @@ fn test_remove_inaccessible_dir() {
|
|||
assert!(!at.dir_exists(dir_1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn test_rm_current_or_parent_dir_rm4() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.mkdir("d");
|
||||
|
||||
let answers = [
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd/.'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd/./'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd/./'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd/..'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd/../'",
|
||||
];
|
||||
let std_err_str = ts
|
||||
.ucmd()
|
||||
.arg("-rf")
|
||||
.arg("d/.")
|
||||
.arg("d/./")
|
||||
.arg("d/.////")
|
||||
.arg("d/..")
|
||||
.arg("d/../")
|
||||
.fails()
|
||||
.stderr_move_str();
|
||||
|
||||
for (idx, line) in std_err_str.lines().enumerate() {
|
||||
assert_eq!(line, answers[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn test_rm_current_or_parent_dir_rm4_windows() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
at.mkdir("d");
|
||||
|
||||
let answers = [
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd\\.'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd\\.\\'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd\\.\\'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd\\..'",
|
||||
"rm: refusing to remove '.' or '..' directory: skipping 'd\\..\\'",
|
||||
];
|
||||
let std_err_str = ts
|
||||
.ucmd()
|
||||
.arg("-rf")
|
||||
.arg("d\\.")
|
||||
.arg("d\\.\\")
|
||||
.arg("d\\.\\\\\\\\")
|
||||
.arg("d\\..")
|
||||
.arg("d\\..\\")
|
||||
.fails()
|
||||
.stderr_move_str();
|
||||
|
||||
for (idx, line) in std_err_str.lines().enumerate() {
|
||||
assert_eq!(line, answers[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn test_fifo_removal() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue