Merge pull request #6000 from BenWiederhake/dev-pipein-fails-flake

tests: Harden two tests, prevent 4 flaky tests (cat, numfmt, sort, split, tee)
This commit is contained in:
Sylvestre Ledru 2024-02-28 09:41:00 +01:00 committed by GitHub
commit 769c5ca7a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 4 deletions

View file

@ -175,6 +175,7 @@ fn test_piped_to_dev_full() {
s.ucmd()
.set_stdout(dev_full)
.pipe_in_fixture("alpha.txt")
.ignore_stdin_write_error()
.fails()
.stderr_contains("No space left on device");
}
@ -224,6 +225,7 @@ fn test_three_directories_and_file_and_stdin() {
"test_directory3",
])
.pipe_in("stdout bytes")
.ignore_stdin_write_error()
.fails()
.stderr_is_fixture("three_directories_and_file_and_stdin.stderr.expected")
.stdout_is(

View file

@ -666,7 +666,12 @@ fn test_invalid_stdin_number_returns_status_2() {
#[test]
fn test_invalid_stdin_number_in_middle_of_input() {
new_ucmd!().pipe_in("100\nhello\n200").fails().code_is(2);
new_ucmd!()
.pipe_in("100\nhello\n200")
.ignore_stdin_write_error()
.fails()
.stdout_is("100\n")
.code_is(2);
}
#[test]

View file

@ -813,8 +813,6 @@ fn test_check_silent() {
#[test]
fn test_check_unique() {
// Due to a clap bug the combination "-cu" does not work. "-c -u" works.
// See https://github.com/clap-rs/clap/issues/2624
new_ucmd!()
.args(&["-c", "-u"])
.pipe_in("A\nA\n")
@ -823,6 +821,16 @@ fn test_check_unique() {
.stderr_only("sort: -:2: disorder: A\n");
}
#[test]
fn test_check_unique_combined() {
new_ucmd!()
.args(&["-cu"])
.pipe_in("A\nA\n")
.fails()
.code_is(1)
.stderr_only("sort: -:2: disorder: A\n");
}
#[test]
fn test_dictionary_and_nonprinting_conflicts() {
let conflicting_args = ["n", "h", "g", "M"];

View file

@ -1068,6 +1068,7 @@ fn test_split_number_oversized_stdin() {
new_ucmd!()
.args(&["--number=3", "---io-blksize=600"])
.pipe_in_fixture("sixhundredfiftyonebytes.txt")
.ignore_stdin_write_error()
.fails()
.stderr_only("split: -: cannot determine input size\n");
}

View file

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