Merge pull request #7426 from cakebaker/tests_replace_run

tests: replace `run()` with `succeeds()` or `fails()`
This commit is contained in:
Sylvestre Ledru
2025-03-09 18:02:12 +01:00
committed by GitHub
39 changed files with 434 additions and 498 deletions
+1 -2
View File
@@ -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");
}
+2 -4
View File
@@ -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);
@@ -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);
}
+7 -7
View File
@@ -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
@@ -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]
+1 -1
View File
@@ -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");
}
+42 -79
View File
@@ -120,8 +120,7 @@ fn test_stdin_stdout() {
new_ucmd!()
.args(&["status=none"])
.pipe_in(input)
.run()
.no_stderr()
.succeeds()
.stdout_only(output);
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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]
@@ -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]
@@ -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"))]
@@ -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);
@@ -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);
@@ -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());
}
@@ -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());
}
@@ -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)]
@@ -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);
@@ -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]
@@ -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")]
@@ -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));
}
@@ -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]
@@ -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]
@@ -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(),
@@ -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(),
@@ -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());
@@ -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());
}
@@ -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());
@@ -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(),
+8 -8
View File
@@ -66,7 +66,7 @@ fn test_keywords() {
fn test_internal_db() {
new_ucmd!()
.arg("-p")
.run()
.succeeds()
.stdout_is_fixture("internal.expected");
}
@@ -74,7 +74,7 @@ fn test_internal_db() {
fn test_ls_colors() {
new_ucmd!()
.arg("--print-ls-colors")
.run()
.succeeds()
.stdout_is_fixture("ls_colors.expected");
}
@@ -83,7 +83,7 @@ fn test_bash_default() {
new_ucmd!()
.env("TERM", "screen")
.arg("-b")
.run()
.succeeds()
.stdout_is_fixture("bash_def.expected");
}
@@ -92,7 +92,7 @@ fn test_csh_default() {
new_ucmd!()
.env("TERM", "screen")
.arg("-c")
.run()
.succeeds()
.stdout_is_fixture("csh_def.expected");
}
#[test]
@@ -100,12 +100,12 @@ fn test_overridable_args() {
new_ucmd!()
.env("TERM", "screen")
.arg("-bc")
.run()
.succeeds()
.stdout_is_fixture("csh_def.expected");
new_ucmd!()
.env("TERM", "screen")
.arg("-cb")
.run()
.succeeds()
.stdout_is_fixture("bash_def.expected");
}
@@ -226,14 +226,14 @@ fn test_helper(file_name: &str, term: &str) {
.env("TERM", term)
.arg("-c")
.arg(format!("{file_name}.txt"))
.run()
.succeeds()
.stdout_is_fixture(format!("{file_name}.csh.expected"));
new_ucmd!()
.env("TERM", term)
.arg("-b")
.arg(format!("{file_name}.txt"))
.run()
.succeeds()
.stdout_is_fixture(format!("{file_name}.sh.expected"));
}
+5 -5
View File
@@ -13,7 +13,7 @@ fn test_invalid_arg() {
fn test_path_with_trailing_slashes() {
new_ucmd!()
.arg("/root/alpha/beta/gamma/delta/epsilon/omega//")
.run()
.succeeds()
.stdout_is("/root/alpha/beta/gamma/delta/epsilon\n");
}
@@ -21,7 +21,7 @@ fn test_path_with_trailing_slashes() {
fn test_path_without_trailing_slashes() {
new_ucmd!()
.arg("/root/alpha/beta/gamma/delta/epsilon/omega")
.run()
.succeeds()
.stdout_is("/root/alpha/beta/gamma/delta/epsilon\n");
}
@@ -52,15 +52,15 @@ fn test_repeated_zero() {
#[test]
fn test_root() {
new_ucmd!().arg("/").run().stdout_is("/\n");
new_ucmd!().arg("/").succeeds().stdout_is("/\n");
}
#[test]
fn test_pwd() {
new_ucmd!().arg(".").run().stdout_is(".\n");
new_ucmd!().arg(".").succeeds().stdout_is(".\n");
}
#[test]
fn test_empty() {
new_ucmd!().arg("").run().stdout_is(".\n");
new_ucmd!().arg("").succeeds().stdout_is(".\n");
}
+11 -8
View File
@@ -210,7 +210,7 @@ fn test_file_option() {
let out = new_ucmd!()
.arg("-f")
.arg("vars.conf.txt")
.run()
.succeeds()
.stdout_move_str();
assert_eq!(
@@ -227,7 +227,7 @@ fn test_combined_file_set() {
.arg("-f")
.arg("vars.conf.txt")
.arg("FOO=bar.alt")
.run()
.succeeds()
.stdout_move_str();
assert_eq!(out.lines().filter(|&line| line == "FOO=bar.alt").count(), 1);
@@ -259,7 +259,7 @@ fn test_unset_invalid_variables() {
// Cannot test input with \0 in it, since output will also contain \0. rlimit::prlimit fails
// with this error: Error { kind: InvalidInput, message: "nul byte found in provided data" }
for var in ["", "a=b"] {
new_ucmd!().arg("-u").arg(var).run().stderr_only(format!(
new_ucmd!().arg("-u").arg(var).fails().stderr_only(format!(
"env: cannot unset {}: Invalid argument\n",
var.quote()
));
@@ -268,14 +268,17 @@ fn test_unset_invalid_variables() {
#[test]
fn test_single_name_value_pair() {
let out = new_ucmd!().arg("FOO=bar").run();
assert!(out.stdout_str().lines().any(|line| line == "FOO=bar"));
new_ucmd!()
.arg("FOO=bar")
.succeeds()
.stdout_str()
.lines()
.any(|line| line == "FOO=bar");
}
#[test]
fn test_multiple_name_value_pairs() {
let out = new_ucmd!().arg("FOO=bar").arg("ABC=xyz").run();
let out = new_ucmd!().arg("FOO=bar").arg("ABC=xyz").succeeds();
assert_eq!(
out.stdout_str()
@@ -299,7 +302,7 @@ fn test_empty_name() {
new_ucmd!()
.arg("-i")
.arg("=xyz")
.run()
.succeeds()
.stderr_only("env: warning: no name specified for value 'xyz'\n");
}
+1 -1
View File
@@ -397,7 +397,7 @@ fn test_comma_with_plus_4() {
fn test_args_override() {
new_ucmd!()
.args(&["-i", "-i", "with-trailing-tab.txt"])
.run()
.succeeds()
.stdout_is(
"// !note: file contains significant whitespace
// * indentation uses <TAB> characters
+14 -8
View File
@@ -155,13 +155,19 @@ fn test_or() {
.succeeds()
.stdout_only("12\n");
new_ucmd!().args(&["", "|", ""]).run().stdout_only("0\n");
new_ucmd!().args(&["", "|", ""]).fails().stdout_only("0\n");
new_ucmd!().args(&["", "|", "0"]).run().stdout_only("0\n");
new_ucmd!().args(&["", "|", "0"]).fails().stdout_only("0\n");
new_ucmd!().args(&["", "|", "00"]).run().stdout_only("0\n");
new_ucmd!()
.args(&["", "|", "00"])
.fails()
.stdout_only("0\n");
new_ucmd!().args(&["", "|", "-0"]).run().stdout_only("0\n");
new_ucmd!()
.args(&["", "|", "-0"])
.fails()
.stdout_only("0\n");
}
#[test]
@@ -188,17 +194,17 @@ fn test_and() {
new_ucmd!()
.args(&["0", "&", "a", "/", "5"])
.run()
.fails()
.stdout_only("0\n");
new_ucmd!()
.args(&["", "&", "a", "/", "5"])
.run()
.fails()
.stdout_only("0\n");
new_ucmd!().args(&["", "&", "1"]).run().stdout_only("0\n");
new_ucmd!().args(&["", "&", "1"]).fails().stdout_only("0\n");
new_ucmd!().args(&["", "&", ""]).run().stdout_only("0\n");
new_ucmd!().args(&["", "&", ""]).fails().stdout_only("0\n");
}
#[test]
+2 -2
View File
@@ -313,7 +313,7 @@ fn run(input_string: &[u8], output_string: &[u8]) {
new_ucmd!()
.timeout(Duration::from_secs(240))
.pipe_in(input_string)
.run()
.succeeds()
.stdout_is(String::from_utf8(output_string.to_owned()).unwrap());
}
@@ -342,7 +342,7 @@ fn test_primes_with_exponents() {
.timeout(Duration::from_secs(240))
.arg("--exponents")
.pipe_in(input_string)
.run()
.succeeds()
.stdout_is(String::from_utf8(output_string.as_bytes().to_owned()).unwrap());
}
+4 -4
View File
@@ -13,7 +13,7 @@ fn test_invalid_arg() {
fn test_default_80_column_wrap() {
new_ucmd!()
.arg("lorem_ipsum.txt")
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_80_column.expected");
}
@@ -21,7 +21,7 @@ fn test_default_80_column_wrap() {
fn test_40_column_hard_cutoff() {
new_ucmd!()
.args(&["-w", "40", "lorem_ipsum.txt"])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_40_column_hard.expected");
}
@@ -29,7 +29,7 @@ fn test_40_column_hard_cutoff() {
fn test_40_column_word_boundary() {
new_ucmd!()
.args(&["-s", "-w", "40", "lorem_ipsum.txt"])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_40_column_word.expected");
}
@@ -37,7 +37,7 @@ fn test_40_column_word_boundary() {
fn test_default_wrap_with_newlines() {
new_ucmd!()
.arg("lorem_ipsum_new_line.txt")
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_new_line_80_column.expected");
}
+3 -3
View File
@@ -19,7 +19,7 @@ fn test_invalid_arg() {
#[cfg(unix)]
fn test_groups() {
let ts = TestScenario::new(util_name!());
let result = ts.ucmd().run();
let result = ts.ucmd().succeeds();
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
result
@@ -34,7 +34,7 @@ fn test_groups_username() {
let test_users = [&whoami()[..]];
let ts = TestScenario::new(util_name!());
let result = ts.ucmd().args(&test_users).run();
let result = ts.ucmd().args(&test_users).succeeds();
let exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
result
@@ -53,7 +53,7 @@ fn test_groups_username_multiple() {
let test_users = ["root", "man", "postfix", "sshd", &whoami()];
let ts = TestScenario::new(util_name!());
let result = ts.ucmd().args(&test_users).run();
let result = ts.ucmd().args(&test_users).fails();
let exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
result
+22 -22
View File
@@ -27,7 +27,7 @@ fn test_invalid_arg() {
fn test_stdin_default() {
new_ucmd!()
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_default.expected");
}
@@ -36,7 +36,7 @@ fn test_stdin_1_line_obsolete() {
new_ucmd!()
.args(&["-1"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_1_line.expected");
}
@@ -45,7 +45,7 @@ fn test_stdin_1_line() {
new_ucmd!()
.args(&["-n", "1"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_1_line.expected");
}
@@ -54,7 +54,7 @@ fn test_stdin_negative_23_line() {
new_ucmd!()
.args(&["-n", "-23"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_1_line.expected");
}
@@ -63,7 +63,7 @@ fn test_stdin_5_chars() {
new_ucmd!()
.args(&["-c", "5"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_5_chars.expected");
}
@@ -71,7 +71,7 @@ fn test_stdin_5_chars() {
fn test_single_default() {
new_ucmd!()
.arg(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_default.expected");
}
@@ -79,7 +79,7 @@ fn test_single_default() {
fn test_single_1_line_obsolete() {
new_ucmd!()
.args(&["-1", INPUT])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_1_line.expected");
}
@@ -87,7 +87,7 @@ fn test_single_1_line_obsolete() {
fn test_single_1_line() {
new_ucmd!()
.args(&["-n", "1", INPUT])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_1_line.expected");
}
@@ -95,7 +95,7 @@ fn test_single_1_line() {
fn test_single_5_chars() {
new_ucmd!()
.args(&["-c", "5", INPUT])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_5_chars.expected");
}
@@ -103,7 +103,7 @@ fn test_single_5_chars() {
fn test_verbose() {
new_ucmd!()
.args(&["-v", INPUT])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_verbose.expected");
}
@@ -117,7 +117,7 @@ fn test_byte_syntax() {
new_ucmd!()
.args(&["-1c"])
.pipe_in("abc")
.run()
.succeeds()
.stdout_is("a");
}
@@ -126,7 +126,7 @@ fn test_line_syntax() {
new_ucmd!()
.args(&["-n", "2048m"])
.pipe_in("a\n")
.run()
.succeeds()
.stdout_is("a\n");
}
@@ -135,7 +135,7 @@ fn test_zero_terminated_syntax() {
new_ucmd!()
.args(&["-z", "-n", "1"])
.pipe_in("x\0y")
.run()
.succeeds()
.stdout_is("x\0");
}
@@ -144,7 +144,7 @@ fn test_zero_terminated_syntax_2() {
new_ucmd!()
.args(&["-z", "-n", "2"])
.pipe_in("x\0y")
.run()
.succeeds()
.stdout_is("x\0y");
}
@@ -153,7 +153,7 @@ fn test_zero_terminated_negative_lines() {
new_ucmd!()
.args(&["-z", "-n", "-1"])
.pipe_in("x\0y\0z\0")
.run()
.succeeds()
.stdout_is("x\0y\0");
}
@@ -162,7 +162,7 @@ fn test_negative_byte_syntax() {
new_ucmd!()
.args(&["--bytes=-2"])
.pipe_in("a\n")
.run()
.succeeds()
.stdout_is("");
}
@@ -241,14 +241,14 @@ fn test_multiple_nonexistent_files() {
fn test_sequence_fixture() {
new_ucmd!()
.args(&["-n", "-10", "sequence"])
.run()
.succeeds()
.stdout_is_fixture("sequence.expected");
}
#[test]
fn test_file_backwards() {
new_ucmd!()
.args(&["-c", "-10", "lorem_ipsum.txt"])
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_backwards_file.expected");
}
@@ -256,7 +256,7 @@ fn test_file_backwards() {
fn test_zero_terminated() {
new_ucmd!()
.args(&["-z", "zero_terminated.txt"])
.run()
.succeeds()
.stdout_is_fixture("zero_terminated.expected");
}
@@ -388,7 +388,7 @@ fn test_presume_input_pipe_default() {
new_ucmd!()
.args(&["---presume-input-pipe"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_default.expected");
}
@@ -397,7 +397,7 @@ fn test_presume_input_pipe_5_chars() {
new_ucmd!()
.args(&["-c", "5", "---presume-input-pipe"])
.pipe_in_fixture(INPUT)
.run()
.succeeds()
.stdout_is_fixture("lorem_ipsum_5_chars.expected");
}
@@ -805,7 +805,7 @@ fn test_write_to_dev_full() {
new_ucmd!()
.pipe_in_fixture(INPUT)
.set_stdout(dev_full)
.run()
.fails()
.stderr_contains("error writing 'standard output': No space left on device");
}
}
+20 -16
View File
@@ -1707,7 +1707,7 @@ fn test_ls_group_directories_first() {
.ucmd()
.arg("-1a")
.arg("--group-directories-first")
.run();
.succeeds();
assert_eq!(
result.stdout_str().split('\n').collect::<Vec<_>>(),
dots.into_iter()
@@ -1721,7 +1721,7 @@ fn test_ls_group_directories_first() {
.ucmd()
.arg("-1ar")
.arg("--group-directories-first")
.run();
.succeeds();
assert_eq!(
result.stdout_str().split('\n').collect::<Vec<_>>(),
(dirnames.into_iter().rev())
@@ -1735,8 +1735,8 @@ fn test_ls_group_directories_first() {
.ucmd()
.arg("-1aU")
.arg("--group-directories-first")
.run();
let result2 = scene.ucmd().arg("-1aU").run();
.succeeds();
let result2 = scene.ucmd().arg("-1aU").succeeds();
assert_eq!(result.stdout_str(), result2.stdout_str());
}
#[test]
@@ -1901,7 +1901,7 @@ fn test_ls_order_birthtime() {
at.make_file("test-birthtime-2").sync_all().unwrap();
at.open("test-birthtime-1");
let result = scene.ucmd().arg("--time=birth").arg("-t").run();
let result = scene.ucmd().arg("--time=birth").arg("-t").succeeds();
#[cfg(not(windows))]
assert_eq!(result.stdout_str(), "test-birthtime-2\ntest-birthtime-1\n");
@@ -2962,7 +2962,7 @@ fn test_ls_human_si() {
.arg("-s")
.arg("+1000k")
.arg(file1)
.run();
.succeeds();
scene
.ucmd()
@@ -4002,13 +4002,13 @@ fn test_ls_sort_extension() {
"", // because of '\n' at the end of the output
];
let result = scene.ucmd().arg("-1aX").run();
let result = scene.ucmd().arg("-1aX").succeeds();
assert_eq!(
result.stdout_str().split('\n').collect::<Vec<_>>(),
expected,
);
let result = scene.ucmd().arg("-1a").arg("--sort=extension").run();
let result = scene.ucmd().arg("-1a").arg("--sort=extension").succeeds();
assert_eq!(
result.stdout_str().split('\n').collect::<Vec<_>>(),
expected,
@@ -4030,26 +4030,30 @@ fn test_ls_path() {
at.touch(path);
let expected_stdout = &format!("{path}\n");
scene.ucmd().arg(path).run().stdout_is(expected_stdout);
scene.ucmd().arg(path).succeeds().stdout_is(expected_stdout);
let expected_stdout = &format!("./{path}\n");
scene
.ucmd()
.arg(format!("./{path}"))
.run()
.succeeds()
.stdout_is(expected_stdout);
let abs_path = format!("{}/{}", at.as_string(), path);
let expected_stdout = format!("{abs_path}\n");
scene.ucmd().arg(&abs_path).run().stdout_is(expected_stdout);
scene
.ucmd()
.arg(&abs_path)
.succeeds()
.stdout_is(expected_stdout);
let expected_stdout = format!("{path}\n{file1}\n");
scene
.ucmd()
.arg(file1)
.arg(path)
.run()
.succeeds()
.stdout_is(expected_stdout);
}
@@ -4299,7 +4303,7 @@ fn test_ls_dereference_looped_symlinks_recursive() {
fn test_dereference_dangling_color() {
let (at, mut ucmd) = at_and_ucmd!();
at.relative_symlink_file("wat", "nonexistent");
let out_exp = ucmd.args(&["--color"]).run().stdout_move_str();
let out_exp = ucmd.args(&["--color"]).succeeds().stdout_move_str();
let (at, mut ucmd) = at_and_ucmd!();
at.relative_symlink_file("wat", "nonexistent");
@@ -4314,7 +4318,7 @@ fn test_dereference_symlink_dir_color() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("dir1");
at.mkdir("dir1/link");
let out_exp = ucmd.args(&["--color", "dir1"]).run().stdout_move_str();
let out_exp = ucmd.args(&["--color", "dir1"]).succeeds().stdout_move_str();
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("dir1");
@@ -4330,7 +4334,7 @@ fn test_dereference_symlink_file_color() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("dir1");
at.touch("dir1/link");
let out_exp = ucmd.args(&["--color", "dir1"]).run().stdout_move_str();
let out_exp = ucmd.args(&["--color", "dir1"]).succeeds().stdout_move_str();
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("dir1");
@@ -4558,7 +4562,7 @@ fn test_ls_dired_outputs_same_date_time_format() {
let at = &scene.fixtures;
at.mkdir("dir");
at.mkdir("dir/a");
let binding = scene.ucmd().arg("-l").arg("dir").run();
let binding = scene.ucmd().arg("-l").arg("dir").succeeds();
let long_output_str = binding.stdout_str();
let split_lines: Vec<&str> = long_output_str.split('\n').collect();
// the second line should contain the long output which includes date
+1 -1
View File
@@ -36,7 +36,7 @@ fn test_mkdir_verbose() {
new_ucmd!()
.arg("test_dir")
.arg("-v")
.run()
.succeeds()
.stdout_is(expected);
}
+12 -4
View File
@@ -954,7 +954,12 @@ fn test_mv_update_option() {
filetime::set_file_times(at.plus_as_string(file_a), now, now).unwrap();
filetime::set_file_times(at.plus_as_string(file_b), now, later).unwrap();
scene.ucmd().arg("--update").arg(file_a).arg(file_b).run();
scene
.ucmd()
.arg("--update")
.arg(file_a)
.arg(file_b)
.succeeds();
assert!(at.file_exists(file_a));
assert!(at.file_exists(file_b));
@@ -1492,11 +1497,14 @@ fn test_mv_into_self_data() {
at.touch(file1);
at.touch(file2);
let result = scene.ucmd().arg(file1).arg(sub_dir).arg(sub_dir).run();
scene
.ucmd()
.arg(file1)
.arg(sub_dir)
.arg(sub_dir)
.fails_with_code(1);
// sub_dir exists, file1 has been moved, file2 still exists.
result.code_is(1);
assert!(at.dir_exists(sub_dir));
assert!(at.file_exists(file1_result_location));
assert!(at.file_exists(file2));
+7 -7
View File
@@ -11,7 +11,7 @@ fn test_get_current_niceness() {
// Test that the nice command with no arguments returns the default nice
// value, which we determine by querying libc's `nice` in our own process.
new_ucmd!()
.run()
.succeeds()
.stdout_is(format!("{}\n", unsafe { libc::nice(0) }));
}
@@ -23,7 +23,7 @@ fn test_negative_adjustment() {
// the OS. If it gets denied, then we know a negative value was parsed
// correctly.
let res = new_ucmd!().args(&["-n", "-1", "true"]).run();
let res = new_ucmd!().args(&["-n", "-1", "true"]).succeeds();
assert!(res
.stderr_str()
.starts_with("nice: warning: setpriority: Permission denied")); // spell-checker:disable-line
@@ -39,14 +39,14 @@ fn test_adjustment_with_no_command_should_error() {
#[test]
fn test_command_with_no_adjustment() {
new_ucmd!().args(&["echo", "a"]).run().stdout_is("a\n");
new_ucmd!().args(&["echo", "a"]).succeeds().stdout_is("a\n");
}
#[test]
fn test_command_with_no_args() {
new_ucmd!()
.args(&["-n", "19", "echo"])
.run()
.succeeds()
.stdout_is("\n");
}
@@ -54,7 +54,7 @@ fn test_command_with_no_args() {
fn test_command_with_args() {
new_ucmd!()
.args(&["-n", "19", "echo", "a", "b", "c"])
.run()
.succeeds()
.stdout_is("a b c\n");
}
@@ -62,7 +62,7 @@ fn test_command_with_args() {
fn test_command_where_command_takes_n_flag() {
new_ucmd!()
.args(&["-n", "19", "echo", "-n", "a"])
.run()
.succeeds()
.stdout_is("a");
}
@@ -75,7 +75,7 @@ fn test_invalid_argument() {
fn test_bare_adjustment() {
new_ucmd!()
.args(&["-1", "echo", "-n", "a"])
.run()
.succeeds()
.stdout_is("a");
}
+5 -5
View File
@@ -15,7 +15,7 @@ fn test_invalid_arg() {
fn test_stdin_no_newline() {
new_ucmd!()
.pipe_in("No Newline")
.run()
.succeeds()
.stdout_is(" 1\tNo Newline\n");
}
@@ -24,7 +24,7 @@ fn test_stdin_newline() {
new_ucmd!()
.args(&["-s", "-", "-w", "1"])
.pipe_in("Line One\nLine Two\n")
.run()
.succeeds()
.stdout_is("1-Line One\n2-Line Two\n");
}
@@ -32,7 +32,7 @@ fn test_stdin_newline() {
fn test_padding_without_overflow() {
new_ucmd!()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "simple.txt"])
.run()
.succeeds()
.stdout_is(
"000001xL1\n001001xL2\n002001xL3\n003001xL4\n004001xL5\n005001xL6\n006001xL7\n0070\
01xL8\n008001xL9\n009001xL10\n010001xL11\n011001xL12\n012001xL13\n013001xL14\n014\
@@ -44,7 +44,7 @@ fn test_padding_without_overflow() {
fn test_padding_with_overflow() {
new_ucmd!()
.args(&["-i", "1000", "-s", "x", "-n", "rz", "-w", "4", "simple.txt"])
.run()
.succeeds()
.stdout_is(
"0001xL1\n1001xL2\n2001xL3\n3001xL4\n4001xL5\n5001xL6\n6001xL7\n7001xL8\n8001xL9\n\
9001xL10\n10001xL11\n11001xL12\n12001xL13\n13001xL14\n14001xL15\n",
@@ -73,7 +73,7 @@ fn test_sections_and_styles() {
.args(&[
"-s", "|", "-n", "ln", "-w", "3", "-b", "a", "-l", "5", fixture,
])
.run()
.succeeds()
.stdout_is(output);
}
// spell-checker:enable
+1 -1
View File
@@ -146,7 +146,7 @@ fn test_combine_pairs_of_lines() {
for d in ["-d", "--delimiters"] {
new_ucmd!()
.args(&[s, d, "\t\n", "html_colors.txt"])
.run()
.succeeds()
.stdout_is_fixture("html_colors.expected");
}
}

Some files were not shown because too many files have changed in this diff Show More