File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
55
6+ #[ cfg( target_os = "linux" ) ]
7+ use std:: {
8+ array,
9+ process:: { Child , Command } ,
10+ } ;
11+
612use crate :: common:: util:: TestScenario ;
713#[ cfg( target_os = "linux" ) ]
814use regex:: Regex ;
@@ -151,37 +157,46 @@ fn test_valid_regex() {
151157 new_ucmd ! ( ) . arg ( "a*" ) . succeeds ( ) ;
152158}
153159
160+ #[ cfg( target_os = "linux" ) ]
161+ fn spawn_2_dummy_sleep_processes ( ) -> [ Child ; 2 ] {
162+ array:: from_fn ( |_| Command :: new ( "sleep" ) . arg ( "2" ) . spawn ( ) . unwrap ( ) )
163+ }
164+
154165#[ cfg( target_os = "linux" ) ]
155166#[ test]
156167fn test_delimiter ( ) {
168+ let mut sleep_processes = spawn_2_dummy_sleep_processes ( ) ;
157169 for arg in [ "-d" , "--delimiter" ] {
158170 new_ucmd ! ( )
159- . arg ( "sh " )
171+ . arg ( "sleep " )
160172 . arg ( arg)
161173 . arg ( "|" )
162174 . succeeds ( )
163175 . stdout_contains ( "|" ) ;
164176 }
177+ sleep_processes. iter_mut ( ) . for_each ( |p| drop ( p. kill ( ) ) ) ;
165178}
166179
167180#[ cfg( target_os = "linux" ) ]
168181#[ test]
169182fn test_delimiter_last_wins ( ) {
183+ let mut sleep_processes = spawn_2_dummy_sleep_processes ( ) ;
170184 new_ucmd ! ( )
171- . arg ( "sh " )
185+ . arg ( "sleep " )
172186 . arg ( "-d_" )
173187 . arg ( "-d:" )
174188 . succeeds ( )
175189 . stdout_does_not_contain ( "_" )
176190 . stdout_contains ( ":" ) ;
177191
178192 new_ucmd ! ( )
179- . arg ( "sh " )
193+ . arg ( "sleep " )
180194 . arg ( "-d:" )
181195 . arg ( "-d_" )
182196 . succeeds ( )
183197 . stdout_does_not_contain ( ":" )
184198 . stdout_contains ( "_" ) ;
199+ sleep_processes. iter_mut ( ) . for_each ( |p| drop ( p. kill ( ) ) ) ;
185200}
186201
187202#[ test]
You can’t perform that action at this time.
0 commit comments