11use std:: {
22 io:: { BufRead , BufReader } ,
3- process:: Command ,
3+ process:: { Child , Command } ,
44 time:: Duration ,
55} ;
66
@@ -22,13 +22,19 @@ fn run_sync_example() -> Result<(), Box<dyn std::error::Error>> {
2222 } ) ;
2323 let output = client. stdout . unwrap ( ) ;
2424 BufReader :: new ( output) . lines ( ) . for_each ( |line| {
25- println ! ( "{}" , line. unwrap( ) ) ;
25+ println ! ( "client output: {}" , line. unwrap( ) ) ;
2626 } ) ;
2727 break ;
2828 }
2929
3030 match client. try_wait ( ) {
3131 Ok ( Some ( status) ) => {
32+ println ! (
33+ "Client exited with status: {:?} success {}" ,
34+ & status,
35+ & status. success( )
36+ ) ;
37+ wait_with_output ( "client" , client) ;
3238 client_succeeded = status. success ( ) ;
3339 break ;
3440 }
@@ -45,6 +51,7 @@ fn run_sync_example() -> Result<(), Box<dyn std::error::Error>> {
4551
4652 // be sure to clean up the server, the client should have run to completion
4753 server. kill ( ) ?;
54+ wait_with_output ( "server" , server) ;
4855 assert ! ( client_succeeded) ;
4956 Ok ( ( ) )
5057}
@@ -59,3 +66,18 @@ fn run_example(example: &str) -> Command {
5966 . current_dir ( "example" ) ;
6067 cmd
6168}
69+
70+ fn wait_with_output ( name : & str , cmd : Child ) {
71+ if let Ok ( output) = cmd. wait_with_output ( ) {
72+ println ! ( "==== {name} output begin" ) ;
73+ println ! ( "==== stdout:" ) ;
74+ output. stdout . lines ( ) . for_each ( |line| {
75+ println ! ( "{}" , line. unwrap( ) ) ;
76+ } ) ;
77+ println ! ( "==== stderr:" ) ;
78+ output. stderr . lines ( ) . for_each ( |line| {
79+ println ! ( "{}" , line. unwrap( ) ) ;
80+ } ) ;
81+ println ! ( "==== {name} output end" ) ;
82+ }
83+ }
0 commit comments