@@ -15,6 +15,7 @@ fn invalid_input() {
1515 new_ucmd ! ( ) . arg ( "-/" ) . fails_with_code ( 125 ) ;
1616}
1717
18+ #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
1819#[ test]
1920fn test_permission ( ) {
2021 new_ucmd ! ( )
@@ -24,6 +25,23 @@ fn test_permission() {
2425 . stderr_contains ( "Permission denied" ) ;
2526}
2627
28+ // TODO: Tests below are brittle when feat_external_libstdbuf is enabled and libstdbuf is not installed.
29+ // Align stdbuf with GNU search order to enable deterministic testing without installation:
30+ // 1) search for libstdbuf next to the stdbuf binary, 2) then in LIBSTDBUF_DIR, 3) then system locations.
31+ // After implementing this, rework tests to provide a temporary symlink rather than depending on system state.
32+
33+ #[ cfg( feature = "feat_external_libstdbuf" ) ]
34+ #[ test]
35+ fn test_permission_external_missing_lib ( ) {
36+ // When built with external libstdbuf, running stdbuf fails early if lib is not installed
37+ new_ucmd ! ( )
38+ . arg ( "-o1" )
39+ . arg ( "." )
40+ . fails_with_code ( 1 )
41+ . stderr_contains ( "External libstdbuf not found" ) ;
42+ }
43+
44+ #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
2745#[ test]
2846fn test_no_such ( ) {
2947 new_ucmd ! ( )
@@ -33,6 +51,17 @@ fn test_no_such() {
3351 . stderr_contains ( "No such file or directory" ) ;
3452}
3553
54+ #[ cfg( feature = "feat_external_libstdbuf" ) ]
55+ #[ test]
56+ fn test_no_such_external_missing_lib ( ) {
57+ // With external lib mode and missing installation, stdbuf fails before spawning the command
58+ new_ucmd ! ( )
59+ . arg ( "-o1" )
60+ . arg ( "no_such" )
61+ . fails_with_code ( 1 )
62+ . stderr_contains ( "External libstdbuf not found" ) ;
63+ }
64+
3665// Disabled on x86_64-unknown-linux-musl because the cross-rs Docker image for this target
3766// does not provide musl-compiled system utilities (like head), leading to dynamic linker errors
3867// when preloading musl-compiled libstdbuf.so into glibc-compiled binaries. Same thing for FreeBSD.
0 commit comments