Skip to content

Commit 769c5ca

Browse files
authored
Merge pull request #6000 from BenWiederhake/dev-pipein-fails-flake
tests: Harden two tests, prevent 4 flaky tests (cat, numfmt, sort, split, tee)
2 parents bd6fc2b + b3d8344 commit 769c5ca

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

tests/by-util/test_cat.rs

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fn test_piped_to_dev_full() {
175175
s.ucmd()
176176
.set_stdout(dev_full)
177177
.pipe_in_fixture("alpha.txt")
178+
.ignore_stdin_write_error()
178179
.fails()
179180
.stderr_contains("No space left on device");
180181
}
@@ -224,6 +225,7 @@ fn test_three_directories_and_file_and_stdin() {
224225
"test_directory3",
225226
])
226227
.pipe_in("stdout bytes")
228+
.ignore_stdin_write_error()
227229
.fails()
228230
.stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected")
229231
.stdout_is(

tests/by-util/test_numfmt.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,12 @@ fn test_invalid_stdin_number_returns_status_2() {
666666

667667
#[test]
668668
fn test_invalid_stdin_number_in_middle_of_input() {
669-
new_ucmd!().pipe_in("100\nhello\n200").fails().code_is(2);
669+
new_ucmd!()
670+
.pipe_in("100\nhello\n200")
671+
.ignore_stdin_write_error()
672+
.fails()
673+
.stdout_is("100\n")
674+
.code_is(2);
670675
}
671676

672677
#[test]

tests/by-util/test_sort.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,6 @@ fn test_check_silent() {
813813

814814
#[test]
815815
fn test_check_unique() {
816-
// Due to a clap bug the combination "-cu" does not work. "-c -u" works.
817-
// See https://github.com/clap-rs/clap/issues/2624
818816
new_ucmd!()
819817
.args(&["-c", "-u"])
820818
.pipe_in("A\nA\n")
@@ -823,6 +821,16 @@ fn test_check_unique() {
823821
.stderr_only("sort: -:2: disorder: A\n");
824822
}
825823

824+
#[test]
825+
fn test_check_unique_combined() {
826+
new_ucmd!()
827+
.args(&["-cu"])
828+
.pipe_in("A\nA\n")
829+
.fails()
830+
.code_is(1)
831+
.stderr_only("sort: -:2: disorder: A\n");
832+
}
833+
826834
#[test]
827835
fn test_dictionary_and_nonprinting_conflicts() {
828836
let conflicting_args = ["n", "h", "g", "M"];

tests/by-util/test_split.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ fn test_split_number_oversized_stdin() {
10681068
new_ucmd!()
10691069
.args(&["--number=3", "---io-blksize=600"])
10701070
.pipe_in_fixture("sixhundredfiftyonebytes.txt")
1071+
.ignore_stdin_write_error()
10711072
.fails()
10721073
.stderr_only("split: -: cannot determine input size\n");
10731074
}

tests/by-util/test_tee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn test_tee_no_more_writeable_1() {
7777
// equals to 'tee /dev/full out2 <multi_read' call
7878
let (at, mut ucmd) = at_and_ucmd!();
7979
let content = (1..=10).fold(String::new(), |mut output, x| {
80-
let _ = writeln!(output, "{x}");
80+
writeln!(output, "{x}").unwrap();
8181
output
8282
});
8383
let file_out = "tee_file_out";

0 commit comments

Comments
 (0)