From bcd2d888a1e3386f96ae4d5151b9e76f525055d2 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 23 Feb 2024 05:02:33 +0100 Subject: [PATCH] cat: don't flake even on exotic pipe buffer sizes See also 9995c637aa5de190ddce0abc4be36d773797f1bc. There is a race condition between the writing thread and the command. It is easily possible that on the developer's machine, the writing thread is always faster, filling the kernel's buffer of the stdin pipe, thus succeeding the write. It is also easily possible that on the busy CI machines, the child command runs first for whatever reason, and exits early, thus killing the pipe, which causes the later write to fail. This results in a flaky test. Let's prevent flaky tests. --- tests/by-util/test_cat.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/by-util/test_cat.rs b/tests/by-util/test_cat.rs index 560709f29..ab8e71899 100644 --- a/tests/by-util/test_cat.rs +++ b/tests/by-util/test_cat.rs @@ -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(