Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/by-util/test_cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ fn test_appending_same_input_output() {
ucmd.set_stdin(file_read);
ucmd.set_stdout(file_write);

ucmd.run()
.failure()
ucmd.fails()
.no_stdout()
.stderr_contains("input file is output file");
}
6 changes: 2 additions & 4 deletions tests/by-util/test_chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ fn test_chmod_symlink_non_existing_file() {
.arg("-v")
.arg("-f")
.arg(test_symlink)
.run()
.code_is(1)
.fails_with_code(1)
.no_stderr()
.stdout_contains(expected_stdout);

Expand All @@ -498,8 +497,7 @@ fn test_chmod_symlink_non_existing_file() {
.ucmd()
.arg("755")
.arg(test_symlink)
.run()
.code_is(1)
.fails_with_code(1)
.no_stdout()
.stderr_contains(expected_stderr);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/by-util/test_chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ fn test_chown_only_owner() {
at.touch(file1);

// since only superuser can change owner, we have to change from ourself to ourself
let result = scene
scene
.ucmd()
.arg(user_name)
.arg("--verbose")
.arg(file1)
.run();
result.stderr_contains("retained as");
.succeeds()
.stderr_contains("retained as");

// try to change to another existing user, e.g. 'root'
scene
Expand Down Expand Up @@ -672,16 +672,16 @@ fn test_chown_recursive() {
at.touch(at.plus_as_string("a/b/c/c"));
at.touch(at.plus_as_string("z/y"));

let result = scene
scene
.ucmd()
.arg("-R")
.arg("--verbose")
.arg(user_name)
.arg("a")
.arg("z")
.run();
result.stderr_contains("ownership of 'a/a' retained as");
result.stderr_contains("ownership of 'z/y' retained as");
.succeeds()
.stderr_contains("ownership of 'a/a' retained as")
.stderr_contains("ownership of 'z/y' retained as");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ mod gnu_cksum_c {
.arg("--warn")
.arg("--check")
.arg("CHECKSUMS")
.run()
.fails()
.stderr_contains("CHECKSUMS: 6: improperly formatted SM3 checksum line")
.stderr_contains("CHECKSUMS: 9: improperly formatted BLAKE2b checksum line");
}
Expand Down
121 changes: 42 additions & 79 deletions tests/by-util/test_dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ fn test_stdin_stdout() {
new_ucmd!()
.args(&["status=none"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}

Expand All @@ -135,8 +134,7 @@ fn test_stdin_stdout_count() {
new_ucmd!()
.args(&["status=none", "count=2", "ibs=128"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}

Expand All @@ -148,8 +146,7 @@ fn test_stdin_stdout_count_bytes() {
new_ucmd!()
.args(&["status=none", "count=256", "iflag=count_bytes"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}

Expand All @@ -161,8 +158,7 @@ fn test_stdin_stdout_skip() {
new_ucmd!()
.args(&["status=none", "skip=2", "ibs=128"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}

Expand All @@ -174,8 +170,7 @@ fn test_stdin_stdout_skip_bytes() {
new_ucmd!()
.args(&["status=none", "skip=256", "ibs=128", "iflag=skip_bytes"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}

Expand All @@ -186,10 +181,8 @@ fn test_stdin_stdout_skip_w_multiplier() {
new_ucmd!()
.args(&["status=none", "skip=5K", "iflag=skip_bytes"])
.pipe_in(input)
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_is(output);
}

#[test]
Expand All @@ -199,10 +192,8 @@ fn test_stdin_stdout_count_w_multiplier() {
new_ucmd!()
.args(&["status=none", "count=2KiB", "iflag=count_bytes"])
.pipe_in(input)
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_only(output);
}

#[test]
Expand Down Expand Up @@ -276,11 +267,10 @@ fn test_final_stats_noxfer() {
#[test]
fn test_final_stats_unspec() {
new_ucmd!()
.run()
.succeeds()
.stderr_contains("0+0 records in\n0+0 records out\n0 bytes copied, ")
.stderr_matches(&Regex::new(r"\d(\.\d+)?(e-\d\d)? s, ").unwrap())
.stderr_contains("0.0 B/s")
.success();
.stderr_contains("0.0 B/s");
}

#[cfg(any(target_os = "linux", target_os = "android"))]
Expand Down Expand Up @@ -308,7 +298,7 @@ fn test_noatime_does_not_update_infile_atime() {

let pre_atime = fix.metadata(fname).accessed().unwrap();

ucmd.run().no_stderr().success();
ucmd.succeeds().no_output();

let post_atime = fix.metadata(fname).accessed().unwrap();
assert_eq!(pre_atime, post_atime);
Expand All @@ -328,7 +318,7 @@ fn test_noatime_does_not_update_ofile_atime() {

let pre_atime = fix.metadata(fname).accessed().unwrap();

ucmd.pipe_in("").run().no_stderr().success();
ucmd.pipe_in("").succeeds().no_output();

let post_atime = fix.metadata(fname).accessed().unwrap();
assert_eq!(pre_atime, post_atime);
Expand Down Expand Up @@ -362,10 +352,8 @@ fn test_notrunc_does_not_truncate() {

let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", "conv=notrunc", of!(&fname), "if=null.txt"])
.run()
.no_stdout()
.no_stderr()
.success();
.succeeds()
.no_output();

assert_eq!(256, fix.metadata(fname).len());
}
Expand All @@ -382,10 +370,8 @@ fn test_existing_file_truncated() {

let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", "if=null.txt", of!(fname)])
.run()
.no_stdout()
.no_stderr()
.success();
.succeeds()
.no_output();

assert_eq!(0, fix.metadata(fname).len());
}
Expand All @@ -394,21 +380,18 @@ fn test_existing_file_truncated() {
fn test_null_stats() {
new_ucmd!()
.arg("if=null.txt")
.run()
.succeeds()
.stderr_contains("0+0 records in\n0+0 records out\n0 bytes copied, ")
.stderr_matches(&Regex::new(r"\d(\.\d+)?(e-\d\d)? s, ").unwrap())
.stderr_contains("0.0 B/s")
.success();
.stderr_contains("0.0 B/s");
}

#[test]
fn test_null_fullblock() {
new_ucmd!()
.args(&["if=null.txt", "status=none", "iflag=fullblock"])
.run()
.no_stdout()
.no_stderr()
.success();
.succeeds()
.no_output();
}

#[cfg(unix)]
Expand Down Expand Up @@ -441,8 +424,7 @@ fn test_fullblock() {
"count=1",
"iflag=fullblock",
])
.run();
ucmd.success();
.succeeds();

let run_stats = &ucmd.stderr()[..exp_stats.len()];
assert_eq!(exp_stats, run_stats);
Expand All @@ -456,10 +438,8 @@ fn test_ys_to_stdout() {

new_ucmd!()
.args(&["status=none", "if=y-nl-1k.txt"])
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_only(output);
}

#[test]
Expand All @@ -468,10 +448,8 @@ fn test_zeros_to_stdout() {
let output = String::from_utf8(output).unwrap();
new_ucmd!()
.args(&["status=none", "if=zero-256k.txt"])
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_only(output);
}

#[cfg(target_pointer_width = "32")]
Expand All @@ -480,9 +458,8 @@ fn test_oversized_bs_32_bit() {
for bs_param in ["bs", "ibs", "obs", "cbs"] {
new_ucmd!()
.args(&[format!("{}=5GB", bs_param)])
.run()
.fails()
.no_stdout()
.failure()
.code_is(1)
.stderr_is(format!("dd: {}=N cannot fit into memory\n", bs_param));
}
Expand All @@ -495,10 +472,8 @@ fn test_to_stdout_with_ibs_obs() {

new_ucmd!()
.args(&["status=none", "if=y-nl-1k.txt", "ibs=521", "obs=1031"])
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_only(output);
}

#[test]
Expand All @@ -509,10 +484,8 @@ fn test_ascii_10k_to_stdout() {

new_ucmd!()
.args(&["status=none", "if=ascii-10k.txt"])
.run()
.no_stderr()
.stdout_is(output)
.success();
.succeeds()
.stdout_only(output);
}

#[test]
Expand All @@ -524,10 +497,8 @@ fn test_zeros_to_file() {

let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", inf!(test_fn), of!(tmp_fn)])
.run()
.no_stderr()
.no_stdout()
.success();
.succeeds()
.no_output();

cmp_file!(
File::open(fixture_path!(&test_fn)).unwrap(),
Expand All @@ -550,10 +521,8 @@ fn test_to_file_with_ibs_obs() {
"ibs=222",
"obs=111",
])
.run()
.no_stderr()
.no_stdout()
.success();
.succeeds()
.no_output();

cmp_file!(
File::open(fixture_path!(&test_fn)).unwrap(),
Expand All @@ -570,10 +539,8 @@ fn test_ascii_521k_to_file() {
let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", of!(tmp_fn)])
.pipe_in(input.clone())
.run()
.no_stderr()
.no_stdout()
.success();
.succeeds()
.no_output();

assert_eq!(512 * 1024, fix.metadata(&tmp_fn).len());

Expand Down Expand Up @@ -602,10 +569,8 @@ fn test_ascii_5_gibi_to_file() {
"if=/dev/zero",
of!(tmp_fn),
])
.run()
.no_stderr()
.no_stdout()
.success();
.succeeds()
.no_output();

assert_eq!(5 * 1024 * 1024 * 1024, fix.metadata(&tmp_fn).len());
}
Expand All @@ -621,7 +586,7 @@ fn test_self_transfer() {
assert!(fix.file_exists(fname));
assert_eq!(256 * 1024, fix.metadata(fname).len());

ucmd.run().no_stdout().no_stderr().success();
ucmd.succeeds().no_output();

assert!(fix.file_exists(fname));
assert_eq!(256 * 1024, fix.metadata(fname).len());
Expand All @@ -636,10 +601,8 @@ fn test_unicode_filenames() {

let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", inf!(test_fn), of!(tmp_fn)])
.run()
.no_stderr()
.no_stdout()
.success();
.succeeds()
.no_output();

cmp_file!(
File::open(fixture_path!(&test_fn)).unwrap(),
Expand Down
Loading
Loading