mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tests: replace run() with succeeds() or fails()
This commit is contained in:
parent
3844a74c38
commit
df4dfea852
39 changed files with 434 additions and 498 deletions
|
@ -36,7 +36,7 @@ fn test_help_and_version_on_stdout() {
|
|||
fn test_stdin_default() {
|
||||
new_ucmd!()
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-simple.expected");
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ fn test_stdin_default() {
|
|||
fn test_single_default() {
|
||||
new_ucmd!()
|
||||
.arg(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-simple.expected");
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ fn test_single_default() {
|
|||
fn test_single_default_output() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let expected = at.read("sorted-simple.expected");
|
||||
ucmd.args(&[INPUT, OUTPUT]).run();
|
||||
ucmd.args(&[INPUT, OUTPUT]).succeeds();
|
||||
let found = at.read(OUTPUT);
|
||||
assert_eq!(found, expected);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ fn test_stdin_counts() {
|
|||
new_ucmd!()
|
||||
.args(&["-c"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-counts.expected");
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ fn test_stdin_skip_1_char() {
|
|||
new_ucmd!()
|
||||
.args(&["-s1"])
|
||||
.pipe_in_fixture(SKIP_CHARS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-1-char.expected");
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ fn test_stdin_skip_5_chars() {
|
|||
new_ucmd!()
|
||||
.args(&["-s5"])
|
||||
.pipe_in_fixture(SKIP_CHARS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-5-chars.expected");
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ fn test_stdin_skip_and_check_2_chars() {
|
|||
new_ucmd!()
|
||||
.args(&["-s3", "-w2"])
|
||||
.pipe_in_fixture(SKIP_CHARS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-3-check-2-chars.expected");
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ fn test_stdin_skip_2_fields() {
|
|||
new_ucmd!()
|
||||
.args(&["-f2"])
|
||||
.pipe_in_fixture(SKIP_FIELDS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-2-fields.expected");
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ fn test_stdin_skip_2_fields_obsolete() {
|
|||
new_ucmd!()
|
||||
.args(&["-2"])
|
||||
.pipe_in_fixture(SKIP_FIELDS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-2-fields.expected");
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ fn test_stdin_skip_21_fields() {
|
|||
new_ucmd!()
|
||||
.args(&["-f21"])
|
||||
.pipe_in_fixture(SKIP_FIELDS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-21-fields.expected");
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ fn test_stdin_skip_21_fields_obsolete() {
|
|||
new_ucmd!()
|
||||
.args(&["-21"])
|
||||
.pipe_in_fixture(SKIP_FIELDS)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("skip-21-fields.expected");
|
||||
}
|
||||
|
||||
|
@ -133,8 +133,7 @@ fn test_stdin_skip_21_fields_obsolete() {
|
|||
fn test_stdin_skip_invalid_fields_obsolete() {
|
||||
new_ucmd!()
|
||||
.args(&["-5q"])
|
||||
.run()
|
||||
.failure()
|
||||
.fails()
|
||||
.stderr_contains("error: unexpected argument '-q' found\n");
|
||||
}
|
||||
|
||||
|
@ -143,22 +142,22 @@ fn test_stdin_all_repeated() {
|
|||
new_ucmd!()
|
||||
.args(&["--all-repeated"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=none"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=non"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=n"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||
}
|
||||
|
||||
|
@ -170,8 +169,7 @@ fn test_all_repeated_followed_by_filename() {
|
|||
at.write(filename, "a\na\n");
|
||||
|
||||
ucmd.args(&["--all-repeated", filename])
|
||||
.run()
|
||||
.success()
|
||||
.succeeds()
|
||||
.stdout_is("a\na\n");
|
||||
}
|
||||
|
||||
|
@ -180,17 +178,17 @@ fn test_stdin_all_repeated_separate() {
|
|||
new_ucmd!()
|
||||
.args(&["--all-repeated=separate"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=separat"]) // spell-checker:disable-line
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=s"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||
}
|
||||
|
||||
|
@ -199,17 +197,17 @@ fn test_stdin_all_repeated_prepend() {
|
|||
new_ucmd!()
|
||||
.args(&["--all-repeated=prepend"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=prepen"]) // spell-checker:disable-line
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--all-repeated=p"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||
}
|
||||
|
||||
|
@ -218,7 +216,7 @@ fn test_stdin_unique_only() {
|
|||
new_ucmd!()
|
||||
.args(&["-u"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-unique-only.expected");
|
||||
}
|
||||
|
||||
|
@ -227,7 +225,7 @@ fn test_stdin_repeated_only() {
|
|||
new_ucmd!()
|
||||
.args(&["-d"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-repeated-only.expected");
|
||||
}
|
||||
|
||||
|
@ -236,7 +234,7 @@ fn test_stdin_ignore_case() {
|
|||
new_ucmd!()
|
||||
.args(&["-i"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-ignore-case.expected");
|
||||
}
|
||||
|
||||
|
@ -245,7 +243,7 @@ fn test_stdin_zero_terminated() {
|
|||
new_ucmd!()
|
||||
.args(&["-z"])
|
||||
.pipe_in_fixture(SORTED_ZERO_TERMINATED)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("sorted-zero-terminated.expected");
|
||||
}
|
||||
|
||||
|
@ -254,8 +252,7 @@ fn test_gnu_locale_fr_schar() {
|
|||
new_ucmd!()
|
||||
.args(&["-f1", "locale-fr-schar.txt"])
|
||||
.env("LC_ALL", "C")
|
||||
.run()
|
||||
.success()
|
||||
.succeeds()
|
||||
.stdout_is_fixture_bytes("locale-fr-schar.txt");
|
||||
}
|
||||
|
||||
|
@ -264,7 +261,7 @@ fn test_group() {
|
|||
new_ucmd!()
|
||||
.args(&["--group"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group.expected");
|
||||
}
|
||||
|
||||
|
@ -276,8 +273,7 @@ fn test_group_followed_by_filename() {
|
|||
at.write(filename, "a\na\n");
|
||||
|
||||
ucmd.args(&["--group", filename])
|
||||
.run()
|
||||
.success()
|
||||
.succeeds()
|
||||
.stdout_is("a\na\n");
|
||||
}
|
||||
|
||||
|
@ -286,12 +282,12 @@ fn test_group_prepend() {
|
|||
new_ucmd!()
|
||||
.args(&["--group=prepend"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-prepend.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=p"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-prepend.expected");
|
||||
}
|
||||
|
||||
|
@ -300,12 +296,12 @@ fn test_group_append() {
|
|||
new_ucmd!()
|
||||
.args(&["--group=append"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-append.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=a"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-append.expected");
|
||||
}
|
||||
|
||||
|
@ -314,17 +310,17 @@ fn test_group_both() {
|
|||
new_ucmd!()
|
||||
.args(&["--group=both"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-both.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=bot"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-both.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=b"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group-both.expected");
|
||||
}
|
||||
|
||||
|
@ -333,18 +329,18 @@ fn test_group_separate() {
|
|||
new_ucmd!()
|
||||
.args(&["--group=separate"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=s"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is_fixture("group.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_case2() {
|
||||
new_ucmd!().pipe_in("a\na\n").run().stdout_is("a\n");
|
||||
new_ucmd!().pipe_in("a\na\n").succeeds().stdout_is("a\n");
|
||||
}
|
||||
|
||||
struct TestCase {
|
||||
|
@ -1179,6 +1175,6 @@ fn test_stdin_w1_multibyte() {
|
|||
new_ucmd!()
|
||||
.args(&["-w1"])
|
||||
.pipe_in(input)
|
||||
.run()
|
||||
.succeeds()
|
||||
.stdout_is("à\ná\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue