mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tests: patch tests to simplify imports
This commit is contained in:
parent
5ce678b1cd
commit
6e23d4e979
63 changed files with 242 additions and 343 deletions
|
@ -102,8 +102,7 @@ fn test_shred_remove_wipesync() {
|
|||
|
||||
#[test]
|
||||
fn test_shred_u() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file_a = "test_shred_remove_a";
|
||||
let file_b = "test_shred_remove_b";
|
||||
|
@ -113,7 +112,7 @@ fn test_shred_u() {
|
|||
at.touch(file_b);
|
||||
|
||||
// Shred file_a.
|
||||
scene.ucmd().arg("-u").arg(file_a).succeeds();
|
||||
ucmd.arg("-u").arg(file_a).succeeds();
|
||||
|
||||
// file_a was deleted, file_b exists.
|
||||
assert!(!at.file_exists(file_a));
|
||||
|
@ -239,13 +238,12 @@ fn test_shred_verbose_no_padding_10() {
|
|||
|
||||
#[test]
|
||||
fn test_all_patterns_present() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "foo.txt";
|
||||
at.write(file, "bar");
|
||||
|
||||
let result = scene.ucmd().arg("-vn25").arg(file).succeeds();
|
||||
let result = ucmd.arg("-vn25").arg(file).succeeds();
|
||||
|
||||
for pat in PATTERNS {
|
||||
result.stderr_contains(pat);
|
||||
|
@ -254,24 +252,28 @@ fn test_all_patterns_present() {
|
|||
|
||||
#[test]
|
||||
fn test_random_source_regular_file() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
// Currently, our block size is 4096. If it changes, this test has to be adapted.
|
||||
let mut many_bytes = Vec::with_capacity(4096 * 4);
|
||||
|
||||
for i in 0..4096u32 {
|
||||
many_bytes.extend(i.to_le_bytes());
|
||||
}
|
||||
|
||||
assert_eq!(many_bytes.len(), 4096 * 4);
|
||||
at.write_bytes("source_long", &many_bytes);
|
||||
|
||||
let file = "foo.txt";
|
||||
at.write(file, "a");
|
||||
scene
|
||||
.ucmd()
|
||||
|
||||
ucmd
|
||||
.arg("-vn3")
|
||||
.arg("--random-source=source_long")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stderr_only("shred: foo.txt: pass 1/3 (random)...\nshred: foo.txt: pass 2/3 (random)...\nshred: foo.txt: pass 3/3 (random)...\n");
|
||||
|
||||
// Should rewrite the file exactly three times
|
||||
assert_eq!(at.read_bytes(file), many_bytes[(4096 * 2)..(4096 * 3)]);
|
||||
}
|
||||
|
@ -279,13 +281,13 @@ fn test_random_source_regular_file() {
|
|||
#[test]
|
||||
#[ignore = "known issue #7947"]
|
||||
fn test_random_source_dir() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("source");
|
||||
let file = "foo.txt";
|
||||
at.write(file, "a");
|
||||
scene
|
||||
.ucmd()
|
||||
|
||||
ucmd
|
||||
.arg("-v")
|
||||
.arg("--random-source=source")
|
||||
.arg(file)
|
||||
|
@ -302,12 +304,15 @@ fn test_shred_rename_exhaustion() {
|
|||
at.touch("test");
|
||||
at.touch("000");
|
||||
|
||||
let result = scene.ucmd().arg("-vu").arg("test").succeeds();
|
||||
|
||||
result.stderr_contains("renamed to 0000");
|
||||
result.stderr_contains("renamed to 001");
|
||||
result.stderr_contains("renamed to 00");
|
||||
result.stderr_contains("removed");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-vu")
|
||||
.arg("test")
|
||||
.succeeds()
|
||||
.stderr_contains("renamed to 0000")
|
||||
.stderr_contains("renamed to 001")
|
||||
.stderr_contains("renamed to 00")
|
||||
.stderr_contains("removed");
|
||||
|
||||
assert!(!at.file_exists("test"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue