File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub fn uu_app() -> Command {
118118 . long ( "interval" )
119119 . help ( "Seconds to wait between updates" )
120120 . default_value ( "2" )
121+ . env ( "WATCH_INTERVAL" )
121122 . value_name ( "SECONDS" ) ,
122123 )
123124 . arg (
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ const TRUE_CMD: &str = "%SYSTEMROOT%\\System32\\rundll32.exe";
1414#[ cfg( not( windows) ) ]
1515const TRUE_CMD : & str = "true" ;
1616
17+ #[ cfg( windows) ]
18+ const ECHO_HELLO_CMD : & str = "echo | set /p dummyName=hello" ;
19+
20+ #[ cfg( not( windows) ) ]
21+ const ECHO_HELLO_CMD : & str = "printf hello" ;
22+
1723#[ test]
1824fn test_invalid_arg ( ) {
1925 new_ucmd ! ( ) . arg ( "--definitely-invalid" ) . fails ( ) . code_is ( 1 ) ;
@@ -62,3 +68,20 @@ fn test_valid_interval_comma() {
6268 . no_stderr ( )
6369 . no_stdout ( ) ;
6470}
71+
72+ #[ test]
73+ fn test_interval_environment_variable ( ) {
74+ let mut p = new_ucmd ! ( )
75+ . arg ( ECHO_HELLO_CMD )
76+ . env ( "WATCH_INTERVAL" , "0.3" )
77+ . run_no_wait ( ) ;
78+ // With 0.5 seconds runtime, the watched command is called twice if
79+ // `WATCH_INTERVAL` (0.3 seconds) is taken into account, but only once if the default
80+ // interval (2 seconds) is used.
81+ p. make_assertion_with_delay ( 500 ) . is_alive ( ) ;
82+ p. kill ( )
83+ . make_assertion ( )
84+ . with_all_output ( )
85+ . no_stderr ( )
86+ . stdout_is_bytes ( b"hellohello" ) ;
87+ }
You can’t perform that action at this time.
0 commit comments