From 9ee6a9d5879a0747fc24cebd3279499396106d81 Mon Sep 17 00:00:00 2001 From: Jake Wallin Date: Fri, 16 Oct 2026 16:31:19 +0000 Subject: [PATCH] stty: enable the BSD cfg alias in integration tests --- Cargo.lock | 1 + Cargo.toml | 1 + build.rs | 10 ++++++++ tests/by-util/test_stty.rs | 48 +++++--------------------------------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b76bab88632..2c1369afdfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -505,6 +505,7 @@ name = "coreutils" version = "0.13.0" dependencies = [ "bytecount", + "cfg_aliases", "clap", "clap_complete", "clap_mangen", diff --git a/Cargo.toml b/Cargo.toml index 2516e91ea15..4f72f87770e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -397,6 +397,7 @@ nix = { workspace = true, features = ["fs", "signal"] } rustix = { workspace = true, features = ["net", "process"] } [build-dependencies] +cfg_aliases.workspace = true phf_codegen.workspace = true [features] diff --git a/build.rs b/build.rs index 923b2f44d1a..f2ce196b0d0 100644 --- a/build.rs +++ b/build.rs @@ -15,6 +15,16 @@ pub fn main() { const FEATURE_PREFIX: &str = "feat_"; const OVERRIDE_PREFIX: &str = "uu_"; + cfg_aliases::cfg_aliases! { + bsd: { any( + target_vendor = "apple", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "openbsd" + ) }, + }; + // Do not rebuild build script unless the script itself or the enabled features are modified // See println!("cargo:rerun-if-changed=build.rs"); diff --git a/tests/by-util/test_stty.rs b/tests/by-util/test_stty.rs index 157758db903..afa4deecaee 100644 --- a/tests/by-util/test_stty.rs +++ b/tests/by-util/test_stty.rs @@ -153,13 +153,7 @@ fn invalid_setting() { #[test] fn invalid_baud_setting() { - #[cfg(not(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(bsd))] new_ucmd!() .args(&["100"]) .fails() @@ -180,25 +174,13 @@ fn invalid_baud_setting() { .fails() .stderr_contains("missing argument to 'ospeed'"); - #[cfg(not(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(bsd))] new_ucmd!() .args(&["ispeed", "995"]) .fails() .stderr_contains("invalid ispeed '995'"); - #[cfg(not(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(bsd))] new_ucmd!() .args(&["ospeed", "995"]) .fails() @@ -471,13 +453,7 @@ fn grouped_flag_removal() { #[ignore = "Fails because cargo test does not run in a tty"] fn baud_rate_validation() { // Test various baud rate formats - #[cfg(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - ))] + #[cfg(bsd)] { // BSD accepts numeric baud rates new_ucmd!().args(&["9600"]).fails(); // Fails due to no TTY, but validates parsing @@ -1473,13 +1449,7 @@ fn invalid_baud_rate() { // On non-BSD systems, test invalid numeric baud rate // On BSD systems, any u32 is accepted, so we skip this test - #[cfg(not(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(bsd))] { new_ucmd!() .args(&["ospeed", "999999999"]) @@ -1632,13 +1602,7 @@ fn test_ispeed_ospeed_valid_speeds() { } #[test] -#[cfg(not(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" -)))] +#[cfg(not(bsd))] #[ignore = "Issue: #9547"] fn test_ispeed_ospeed_invalid_speeds() { let (path, _controller, _replica) = pty_path();