File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -825,9 +825,24 @@ mod cmp {
825825 . spawn ( )
826826 . unwrap ( ) ;
827827
828- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
829-
830- assert_eq ! ( child. try_wait( ) . unwrap( ) . unwrap( ) . code( ) , Some ( 1 ) ) ;
828+ // Bound the runtime to a very short time that still allows for some resource
829+ // constraint to slow it down while also allowing very fast systems to exit as
830+ // early as possible.
831+ const MAX_TRIES : u8 = 50 ;
832+ for tries in 0 ..=MAX_TRIES {
833+ if tries == MAX_TRIES {
834+ panic ! ( "cmp took too long to run, /dev/null optimization probably not working" )
835+ }
836+ match child. try_wait ( ) {
837+ Ok ( Some ( status) ) => {
838+ assert_eq ! ( status. code( ) , Some ( 1 ) ) ;
839+ break ;
840+ }
841+ Ok ( None ) => ( ) ,
842+ Err ( e) => panic ! ( "{e:#?}" ) ,
843+ }
844+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
845+ }
831846
832847 // Two stdins should be equal
833848 let mut cmd = cargo_bin_cmd ! ( "diffutils" ) ;
@@ -864,6 +879,7 @@ mod cmp {
864879 let mut cmd = cargo_bin_cmd ! ( "diffutils" ) ;
865880 cmd. arg ( "cmp" ) ;
866881 cmd. arg ( & a_path) . arg ( & b_path) ;
882+ cmd. env ( "LC_ALL" , "en_US" ) ;
867883 cmd. assert ( )
868884 . code ( predicate:: eq ( 1 ) )
869885 . failure ( )
You can’t perform that action at this time.
0 commit comments