@@ -149,31 +149,28 @@ async fn execute_block_works() {
149149 . unwrap ( )
150150 }
151151
152- let mut block_execution = execute_block_range ( & ws_url, from, to) ;
152+ let block_execution = execute_block_range ( & ws_url, from, to) ;
153+
154+ // Let the process run to completion and capture its full output. `Child::stderr` is an
155+ // `Option` that can only be `take()`n once, and `wait_for_stream_pattern_match` stops
156+ // reading as soon as it finds a match, so streaming it twice would either panic on the
157+ // second `take()` or silently miss data buffered past the first match. Capturing the
158+ // full output up front and matching against it lets us check both conditions safely.
159+ let output = block_execution. wait_with_output ( ) . await . unwrap ( ) ;
160+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
153161
154162 // Expect the last block in the range to be successfully executed.
155163 let expected_output = format ! ( r#".*Block #{} successfully executed"# , to) ;
156164 let re = Regex :: new ( expected_output. as_str ( ) ) . unwrap ( ) ;
157- let matched =
158- common:: wait_for_stream_pattern_match ( block_execution. stderr . take ( ) . unwrap ( ) , re) . await ;
159-
160- // Assert that all blocks in the range were executed.
161- assert ! ( matched. is_ok( ) ) ;
165+ assert ! ( re. is_match( & stderr) ) ;
162166
163167 // Assert that the block after is not executed.
164168 let expected_output = format ! ( r#".*Block #{} successfully executed"# , to + 1 ) ;
165169 let re = Regex :: new ( expected_output. as_str ( ) ) . unwrap ( ) ;
166- let matched =
167- common:: wait_for_stream_pattern_match ( block_execution. stderr . take ( ) . unwrap ( ) , re) . await ;
168- assert ! ( matched. is_err( ) ) ;
170+ assert ! ( !re. is_match( & stderr) ) ;
169171
170172 // Assert that the block-execution exited successfully.
171- assert ! ( block_execution
172- . wait_with_output( )
173- . await
174- . unwrap( )
175- . status
176- . success( ) ) ;
173+ assert ! ( output. status. success( ) ) ;
177174 } )
178175 . await
179176}
0 commit comments