From e5bde075916e9f01fb239559d5f087c7e6d7bc82 Mon Sep 17 00:00:00 2001 From: Will Shuttleworth Date: Fri, 13 Jun 2025 03:44:18 -0400 Subject: [PATCH] tail: fix test that disables output in bash shell (#8157) * tail: fix test that disables output in bash shell * tail: fix platform related issues after test change * tail: use new imports on same platforms as test they are needed for --- tests/by-util/test_tail.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 736182bfe..e70133283 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -13,6 +13,20 @@ clippy::cast_possible_truncation )] +#[cfg(all( + not(target_vendor = "apple"), + not(target_os = "windows"), + not(target_os = "android"), + not(target_os = "freebsd") +))] +use nix::sys::signal::{Signal, kill}; +#[cfg(all( + not(target_vendor = "apple"), + not(target_os = "windows"), + not(target_os = "android"), + not(target_os = "freebsd") +))] +use nix::unistd::Pid; use pretty_assertions::assert_eq; use rand::distr::Alphanumeric; use rstest::rstest; @@ -679,7 +693,7 @@ fn test_follow_invalid_pid() { )); } -// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') This test also breaks tty settings under bash requiring a 'stty sane' or reset. // spell-checker:disable-line +// FixME: test PASSES for usual windows builds, but fails for coverage testing builds (likely related to the specific RUSTFLAGS '-Zpanic_abort_tests -Cpanic=abort') // spell-checker:disable-line // FIXME: FreeBSD: See issue https://github.com/uutils/coreutils/issues/4306 // Fails intermittently in the CI, but couldn't reproduce the failure locally. #[test] @@ -694,12 +708,7 @@ fn test_follow_with_pid() { let (at, mut ucmd) = at_and_ucmd!(); - #[cfg(unix)] let dummy_cmd = "sh"; - - #[cfg(windows)] - let dummy_cmd = "cmd"; - let mut dummy = Command::new(dummy_cmd).spawn().unwrap(); let pid = dummy.id(); @@ -734,7 +743,7 @@ fn test_follow_with_pid() { .stdout_only_fixture("foobar_follow_multiple_appended.expected"); // kill the dummy process and give tail time to notice this - dummy.kill().unwrap(); + kill(Pid::from_raw(i32::try_from(pid).unwrap()), Signal::SIGUSR1).unwrap(); let _ = dummy.wait(); child.delay(DEFAULT_SLEEP_INTERVAL_MILLIS);