mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
shred: Implemented --force option (#2012)
This commit is contained in:
parent
9ae4928b7b
commit
18191f9212
3 changed files with 112 additions and 14 deletions
|
@ -1 +1,51 @@
|
|||
// ToDO: add tests
|
||||
use crate::common::util::*;
|
||||
|
||||
#[test]
|
||||
fn test_shred_remove() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file_a = "test_shred_remove_a";
|
||||
let file_b = "test_shred_remove_b";
|
||||
|
||||
// Create file_a and file_b.
|
||||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
|
||||
// Shred file_a.
|
||||
scene.ucmd().arg("-u").arg(file_a).run();
|
||||
|
||||
// file_a was deleted, file_b exists.
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
#[test]
|
||||
fn test_shred_force() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file = "test_shred_force";
|
||||
|
||||
// Create file_a.
|
||||
at.touch(file);
|
||||
assert!(at.file_exists(file));
|
||||
|
||||
// Make file_a readonly.
|
||||
at.set_readonly(file);
|
||||
|
||||
// Try shred -u.
|
||||
let result = scene.ucmd().arg("-u").arg(file).run();
|
||||
println!("stderr = {:?}", result.stderr);
|
||||
println!("stdout = {:?}", result.stdout);
|
||||
|
||||
// file_a was not deleted because it is readonly.
|
||||
assert!(at.file_exists(file));
|
||||
|
||||
// Try shred -u -f.
|
||||
scene.ucmd().arg("-u").arg("-f").arg(file).run();
|
||||
|
||||
// file_a was deleted.
|
||||
assert!(!at.file_exists(file));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue