1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.

Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
This commit is contained in:
Joining7943 2023-01-05 21:09:15 +01:00
parent 7c0ed0340b
commit 1fadeb43b2
40 changed files with 229 additions and 211 deletions

View file

@ -213,7 +213,7 @@ fn test_up_to_match_repeat_over() {
ucmd.args(&["numbers50.txt", "/9$/", "{50}"])
.fails()
.stdout_is("16\n29\n30\n30\n30\n6\n")
.stderr_is("csplit: '/9$/': match not found on repetition 5");
.stderr_is("csplit: '/9$/': match not found on repetition 5\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -224,7 +224,7 @@ fn test_up_to_match_repeat_over() {
ucmd.args(&["numbers50.txt", "/9$/", "{50}", "-k"])
.fails()
.stdout_is("16\n29\n30\n30\n30\n6\n")
.stderr_is("csplit: '/9$/': match not found on repetition 5");
.stderr_is("csplit: '/9$/': match not found on repetition 5\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -370,7 +370,7 @@ fn test_option_keep() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-k", "numbers50.txt", "/20/", "/nope/"])
.fails()
.stderr_is("csplit: '/nope/': match not found")
.stderr_is("csplit: '/nope/': match not found\n")
.stdout_is("48\n93\n");
let count = glob(&at.plus_as_string("xx*"))
@ -546,7 +546,7 @@ fn test_up_to_match_context_overflow() {
ucmd.args(&["numbers50.txt", "/45/+10"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/45/+10': line number out of range");
.stderr_is("csplit: '/45/+10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -557,7 +557,7 @@ fn test_up_to_match_context_overflow() {
ucmd.args(&["numbers50.txt", "/45/+10", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/45/+10': line number out of range");
.stderr_is("csplit: '/45/+10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -572,7 +572,7 @@ fn test_skip_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "%5%-10"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '%5%-10': line number out of range");
.stderr_is("csplit: '%5%-10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -583,7 +583,7 @@ fn test_skip_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "%5%-10", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '%5%-10': line number out of range");
.stderr_is("csplit: '%5%-10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -597,7 +597,7 @@ fn test_skip_to_match_context_overflow() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%45%+10"])
.fails()
.stderr_only("csplit: '%45%+10': line number out of range");
.stderr_is("csplit: '%45%+10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -607,7 +607,7 @@ fn test_skip_to_match_context_overflow() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%45%+10", "-k"])
.fails()
.stderr_only("csplit: '%45%+10': line number out of range");
.stderr_only("csplit: '%45%+10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -621,7 +621,7 @@ fn test_up_to_no_match1() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/"])
.fails()
.stdout_is("6\n135\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -632,7 +632,7 @@ fn test_up_to_no_match1() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "-k"])
.fails()
.stdout_is("6\n135\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -648,7 +648,7 @@ fn test_up_to_no_match2() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}"])
.fails()
.stdout_is("6\n135\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -659,7 +659,7 @@ fn test_up_to_no_match2() {
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}", "-k"])
.fails()
.stdout_is("6\n135\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -675,7 +675,7 @@ fn test_up_to_no_match3() {
ucmd.args(&["numbers50.txt", "/0$/", "{50}"])
.fails()
.stdout_is("18\n30\n30\n30\n30\n3\n")
.stderr_is("csplit: '/0$/': match not found on repetition 5");
.stderr_is("csplit: '/0$/': match not found on repetition 5\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -686,7 +686,7 @@ fn test_up_to_no_match3() {
ucmd.args(&["numbers50.txt", "/0$/", "{50}", "-k"])
.fails()
.stdout_is("18\n30\n30\n30\n30\n3\n")
.stderr_is("csplit: '/0$/': match not found on repetition 5");
.stderr_is("csplit: '/0$/': match not found on repetition 5\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -706,7 +706,7 @@ fn test_up_to_no_match4() {
ucmd.args(&["numbers50.txt", "/nope/", "/4/"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -717,7 +717,7 @@ fn test_up_to_no_match4() {
ucmd.args(&["numbers50.txt", "/nope/", "/4/", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -746,7 +746,7 @@ fn test_up_to_no_match6() {
ucmd.args(&["numbers50.txt", "/nope/-5"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/-5': match not found");
.stderr_is("csplit: '/nope/-5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -757,7 +757,7 @@ fn test_up_to_no_match6() {
ucmd.args(&["numbers50.txt", "/nope/-5", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/-5': match not found");
.stderr_is("csplit: '/nope/-5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -772,7 +772,7 @@ fn test_up_to_no_match7() {
ucmd.args(&["numbers50.txt", "/nope/+5"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/+5': match not found");
.stderr_is("csplit: '/nope/+5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -783,7 +783,7 @@ fn test_up_to_no_match7() {
ucmd.args(&["numbers50.txt", "/nope/+5", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/+5': match not found");
.stderr_is("csplit: '/nope/+5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -797,7 +797,7 @@ fn test_skip_to_no_match1() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%"])
.fails()
.stderr_only("csplit: '%nope%': match not found");
.stderr_only("csplit: '%nope%': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -810,7 +810,7 @@ fn test_skip_to_no_match2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%", "{50}"])
.fails()
.stderr_only("csplit: '%nope%': match not found");
.stderr_only("csplit: '%nope%': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -823,7 +823,7 @@ fn test_skip_to_no_match3() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%0$%", "{50}"])
.fails()
.stderr_only("csplit: '%0$%': match not found on repetition 5");
.stderr_only("csplit: '%0$%': match not found on repetition 5\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -836,7 +836,7 @@ fn test_skip_to_no_match4() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%", "/4/"])
.fails()
.stderr_only("csplit: '%nope%': match not found");
.stderr_only("csplit: '%nope%': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -863,7 +863,7 @@ fn test_skip_to_no_match6() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%-5"])
.fails()
.stderr_only("csplit: '%nope%-5': match not found");
.stderr_only("csplit: '%nope%-5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -876,7 +876,7 @@ fn test_skip_to_no_match7() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%+5"])
.fails()
.stderr_only("csplit: '%nope%+5': match not found");
.stderr_only("csplit: '%nope%+5': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -889,7 +889,7 @@ fn test_no_match() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "%nope%"])
.fails()
.stderr_only("csplit: '%nope%': match not found");
.stderr_only("csplit: '%nope%': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -900,7 +900,7 @@ fn test_no_match() {
ucmd.args(&["numbers50.txt", "/nope/"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '/nope/': match not found");
.stderr_is("csplit: '/nope/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -997,7 +997,7 @@ fn test_too_small_line_num_repeat() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"])
.fails()
.stderr_is("csplit: '10': line number out of range on repetition 5")
.stderr_is("csplit: '10': line number out of range on repetition 5\n")
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1008,7 +1008,7 @@ fn test_too_small_line_num_repeat() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}", "-k"])
.fails()
.stderr_is("csplit: '10': line number out of range on repetition 5")
.stderr_is("csplit: '10': line number out of range on repetition 5\n")
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1030,7 +1030,7 @@ fn test_line_num_out_of_range1() {
ucmd.args(&["numbers50.txt", "100"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '100': line number out of range");
.stderr_is("csplit: '100': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1041,7 +1041,7 @@ fn test_line_num_out_of_range1() {
ucmd.args(&["numbers50.txt", "100", "-k"])
.fails()
.stdout_is("141\n")
.stderr_is("csplit: '100': line number out of range");
.stderr_is("csplit: '100': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1056,7 +1056,7 @@ fn test_line_num_out_of_range2() {
ucmd.args(&["numbers50.txt", "10", "100"])
.fails()
.stdout_is("18\n123\n")
.stderr_is("csplit: '100': line number out of range");
.stderr_is("csplit: '100': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1067,7 +1067,7 @@ fn test_line_num_out_of_range2() {
ucmd.args(&["numbers50.txt", "10", "100", "-k"])
.fails()
.stdout_is("18\n123\n")
.stderr_is("csplit: '100': line number out of range");
.stderr_is("csplit: '100': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1083,7 +1083,7 @@ fn test_line_num_out_of_range3() {
ucmd.args(&["numbers50.txt", "40", "{2}"])
.fails()
.stdout_is("108\n33\n")
.stderr_is("csplit: '40': line number out of range on repetition 1");
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1094,7 +1094,7 @@ fn test_line_num_out_of_range3() {
ucmd.args(&["numbers50.txt", "40", "{2}", "-k"])
.fails()
.stdout_is("108\n33\n")
.stderr_is("csplit: '40': line number out of range on repetition 1");
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1110,7 +1110,7 @@ fn test_line_num_out_of_range4() {
ucmd.args(&["numbers50.txt", "40", "{*}"])
.fails()
.stdout_is("108\n33\n")
.stderr_is("csplit: '40': line number out of range on repetition 1");
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1121,7 +1121,7 @@ fn test_line_num_out_of_range4() {
ucmd.args(&["numbers50.txt", "40", "{*}", "-k"])
.fails()
.stdout_is("108\n33\n")
.stderr_is("csplit: '40': line number out of range on repetition 1");
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1137,7 +1137,7 @@ fn test_skip_to_match_negative_offset_before_a_match() {
ucmd.args(&["numbers50.txt", "/20/-10", "/15/"])
.fails()
.stdout_is("18\n123\n")
.stderr_is("csplit: '/15/': match not found");
.stderr_is("csplit: '/15/': match not found\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("there should be splits created")
@ -1182,7 +1182,7 @@ fn test_corner_case2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/10/-5", "/10/"])
.fails()
.stderr_is("csplit: '/10/': match not found")
.stderr_is("csplit: '/10/': match not found\n")
.stdout_is("8\n133\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1196,7 +1196,7 @@ fn test_corner_case3() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "/15/-3", "14", "/15/"])
.fails()
.stderr_is("csplit: '/15/': match not found")
.stderr_is("csplit: '/15/': match not found\n")
.stdout_is("24\n6\n111\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1228,7 +1228,7 @@ fn test_up_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "/5/-10"])
.fails()
.stdout_is("0\n141\n")
.stderr_is("csplit: '/5/-10': line number out of range");
.stderr_is("csplit: '/5/-10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -1239,7 +1239,7 @@ fn test_up_to_match_context_underflow() {
ucmd.args(&["numbers50.txt", "/5/-10", "-k"])
.fails()
.stdout_is("0\n141\n")
.stderr_is("csplit: '/5/-10': line number out of range");
.stderr_is("csplit: '/5/-10': line number out of range\n");
let count = glob(&at.plus_as_string("xx*"))
.expect("counting splits")
@ -1256,7 +1256,7 @@ fn test_line_num_range_with_up_to_match1() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-5"])
.fails()
.stderr_is("csplit: '/12/-5': line number out of range")
.stderr_is("csplit: '/12/-5': line number out of range\n")
.stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1267,7 +1267,7 @@ fn test_line_num_range_with_up_to_match1() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-5", "-k"])
.fails()
.stderr_is("csplit: '/12/-5': line number out of range")
.stderr_is("csplit: '/12/-5': line number out of range\n")
.stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1286,7 +1286,7 @@ fn test_line_num_range_with_up_to_match2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-15"])
.fails()
.stderr_is("csplit: '/12/-15': line number out of range")
.stderr_is("csplit: '/12/-15': line number out of range\n")
.stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1297,7 +1297,7 @@ fn test_line_num_range_with_up_to_match2() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/12/-15", "-k"])
.fails()
.stderr_is("csplit: '/12/-15': line number out of range")
.stderr_is("csplit: '/12/-15': line number out of range\n")
.stdout_is("18\n0\n123\n");
let count = glob(&at.plus_as_string("xx*"))
@ -1315,7 +1315,7 @@ fn test_line_num_range_with_up_to_match3() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["numbers50.txt", "10", "/10/", "-k"])
.fails()
.stderr_is("csplit: '/10/': match not found")
.stderr_is("csplit: '/10/': match not found\n")
.stdout_is("18\n123\n");
let count = glob(&at.plus_as_string("xx*"))