From e860eb899e358f7f04fae011bd05d65c2010f165 Mon Sep 17 00:00:00 2001 From: Joining7943 <111500881+Joining7943@users.noreply.github.com> Date: Thu, 8 Sep 2022 19:13:49 +0200 Subject: [PATCH] tests/common/util: Add test which provokes the broken pipe error --- tests/common/util.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/common/util.rs b/tests/common/util.rs index 46bf4d85e..d67c27a59 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -1828,4 +1828,22 @@ mod tests { println!("TEST SKIPPED (cannot run inside CI)"); } } + + // This error was first detected when running tail so tail is used here but + // should fail with any command that takes piped input. + // See also https://github.com/uutils/coreutils/issues/3895 + #[test] + fn test_when_piped_input_then_no_broken_pipe() { + let ts = TestScenario::new("tail"); + for i in 0..10000 { + dbg!(i); + let test_string = "a\nb\n"; + ts.ucmd() + .args(&["-n", "0"]) + .pipe_in(test_string) + .succeeds() + .no_stdout() + .no_stderr(); + } + } }