33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
55// spell-checker:ignore cmdline dyld dylib PDEATHSIG setvbuf
6+
67#[ cfg( target_os = "linux" ) ]
78use uutests:: at_and_ucmd;
8- use uutests:: new_ucmd;
9- #[ cfg( not( target_os = "windows" ) ) ]
10- use uutests:: util:: TestScenario ;
11- use uutests:: util_name;
9+ #[ cfg( unix) ]
10+ use uutests:: { new_ucmd, util:: TestScenario , util_name} ;
1211
1312#[ test]
13+ #[ cfg( unix) ]
1414fn invalid_input ( ) {
1515 new_ucmd ! ( ) . arg ( "-/" ) . fails_with_code ( 125 ) ;
1616}
1717
18- #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
18+ #[ cfg( all ( unix , not( feature = "feat_external_libstdbuf" ) ) ) ]
1919#[ test]
2020fn test_permission ( ) {
2121 new_ucmd ! ( )
@@ -28,7 +28,7 @@ fn test_permission() {
2828// LD_DEBUG is not available on macOS, OpenBSD, Android, or musl
2929#[ cfg( all(
3030 feature = "feat_external_libstdbuf" ,
31- not ( target_os = "windows" ) ,
31+ unix ,
3232 not( target_os = "openbsd" ) ,
3333 not( target_os = "macos" ) ,
3434 not( target_os = "android" ) ,
@@ -121,7 +121,7 @@ fn test_stdbuf_search_order_exe_dir_first() {
121121 ) ;
122122}
123123
124- #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
124+ #[ cfg( all ( unix , not( feature = "feat_external_libstdbuf" ) ) ) ]
125125#[ test]
126126fn test_no_such ( ) {
127127 new_ucmd ! ( )
@@ -135,7 +135,7 @@ fn test_no_such() {
135135// does not provide musl-compiled system utilities (like head), leading to dynamic linker errors
136136// when preloading musl-compiled libstdbuf.so into glibc-compiled binaries. Same thing for FreeBSD.
137137#[ cfg( all(
138- not ( target_os = "windows" ) ,
138+ unix ,
139139 not( target_os = "freebsd" ) ,
140140 not( target_os = "openbsd" ) ,
141141 not( all( target_arch = "x86_64" , target_env = "musl" ) )
@@ -157,7 +157,7 @@ fn test_stdbuf_unbuffered_stdout() {
157157// does not provide musl-compiled system utilities (like head), leading to dynamic linker errors
158158// when preloading musl-compiled libstdbuf.so into glibc-compiled binaries. Same thing for FreeBSD.
159159#[ cfg( all(
160- not ( target_os = "windows" ) ,
160+ unix ,
161161 not( target_os = "freebsd" ) ,
162162 not( target_os = "openbsd" ) ,
163163 not( all( target_arch = "x86_64" , target_env = "musl" ) )
@@ -174,8 +174,8 @@ fn test_stdbuf_line_buffered_stdout() {
174174 . stdout_is ( "The quick brown fox jumps over the lazy dog." ) ;
175175}
176176
177- #[ cfg( not( target_os = "windows" ) ) ]
178177#[ test]
178+ #[ cfg( unix) ]
179179fn test_stdbuf_no_buffer_option_fails ( ) {
180180 let ts = TestScenario :: new ( util_name ! ( ) ) ;
181181
@@ -185,8 +185,8 @@ fn test_stdbuf_no_buffer_option_fails() {
185185 . stderr_contains ( "the following required arguments were not provided:" ) ;
186186}
187187
188- #[ cfg( not( target_os = "windows" ) ) ]
189188#[ test]
189+ #[ cfg( unix) ]
190190fn test_stdbuf_no_command_fails_with_125 ( ) {
191191 // Test that missing command fails with exit code 125 (stdbuf error)
192192 // This verifies proper error handling without unwrap panic
@@ -200,7 +200,7 @@ fn test_stdbuf_no_command_fails_with_125() {
200200// does not provide musl-compiled system utilities (like tail), leading to dynamic linker errors
201201// when preloading musl-compiled libstdbuf.so into glibc-compiled binaries. Same thing for FreeBSD.
202202#[ cfg( all(
203- not ( target_os = "windows" ) ,
203+ unix ,
204204 not( target_os = "freebsd" ) ,
205205 not( target_os = "openbsd" ) ,
206206 not( all( target_arch = "x86_64" , target_env = "musl" ) )
@@ -214,17 +214,17 @@ fn test_stdbuf_trailing_var_arg() {
214214 . stdout_is ( "jumps over the lazy dog." ) ;
215215}
216216
217- #[ cfg( not( target_os = "windows" ) ) ]
218217#[ test]
218+ #[ cfg( unix) ]
219219fn test_stdbuf_line_buffering_stdin_fails ( ) {
220220 new_ucmd ! ( )
221221 . args ( & [ "-i" , "L" , "head" ] )
222222 . fails ( )
223223 . usage_error ( "line buffering stdin is meaningless" ) ;
224224}
225225
226- #[ cfg( not( target_os = "windows" ) ) ]
227226#[ test]
227+ #[ cfg( unix) ]
228228fn test_stdbuf_invalid_mode_fails ( ) {
229229 let options = [ "--input" , "--output" , "--error" ] ;
230230 for option in & options {
@@ -254,7 +254,7 @@ fn test_stdbuf_invalid_mode_fails() {
254254// and is sometimes disabled. Disable test on Android for now.
255255// musl libc dynamic loader does not support LD_DEBUG, so disable on musl targets as well.
256256#[ cfg( all(
257- not ( target_os = "windows" ) ,
257+ unix ,
258258 not( target_os = "openbsd" ) ,
259259 not( target_os = "macos" ) ,
260260 not( target_os = "android" ) ,
0 commit comments