@@ -17,7 +17,7 @@ fn is_terminal() {
1717 } ) ) ;
1818
1919 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
20- terminal. read_to_end ( ) . unwrap ( ) ;
20+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
2121 let output = terminal. screen_contents ( ) ;
2222 assert_eq ! ( output. trim( ) , "true true true" ) ;
2323}
@@ -31,7 +31,7 @@ fn read_until_single() {
3131
3232 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
3333 terminal. read_until ( "hello" ) . unwrap ( ) ;
34- terminal. read_to_end ( ) . unwrap ( ) ;
34+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
3535 let output = terminal. screen_contents ( ) ;
3636 // After reading until "hello", the buffer should contain " world"
3737 // read_to_end should process the buffered data and continue reading
@@ -51,7 +51,7 @@ fn read_until_multiple_sequential() {
5151 terminal. read_until ( "first" ) . unwrap ( ) ;
5252 terminal. read_until ( "second" ) . unwrap ( ) ;
5353 terminal. read_until ( "third" ) . unwrap ( ) ;
54- terminal. read_to_end ( ) . unwrap ( ) ;
54+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
5555 let output = terminal. screen_contents ( ) ;
5656 // All three words should be in the screen
5757 assert ! ( output. contains( "first" ) ) ;
@@ -86,7 +86,7 @@ fn read_until_with_read_to_end() {
8686 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
8787 terminal. read_until ( "middle" ) . unwrap ( ) ;
8888 // At this point, " suffix" should be buffered
89- terminal. read_to_end ( ) . unwrap ( ) ;
89+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
9090 let output = terminal. screen_contents ( ) ;
9191 // The full output should include everything
9292 assert ! ( output. contains( "prefix" ) ) ;
@@ -122,7 +122,7 @@ fn read_until_boundary_spanning() {
122122 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
123123 // Search for a pattern that's likely to span boundaries
124124 terminal. read_until ( "abcd" ) . unwrap ( ) ;
125- terminal. read_to_end ( ) . unwrap ( ) ;
125+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
126126 let output = terminal. screen_contents ( ) ;
127127 assert ! ( output. contains( "abcdef" ) ) ;
128128}
@@ -142,7 +142,7 @@ fn read_until_exact_boundary() {
142142 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
143143 // This should find "second" even if "first" was in a previous read
144144 terminal. read_until ( "second" ) . unwrap ( ) ;
145- terminal. read_to_end ( ) . unwrap ( ) ;
145+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
146146 let output = terminal. screen_contents ( ) ;
147147 assert ! ( output. contains( "first" ) ) ;
148148 assert ! ( output. contains( "second" ) ) ;
@@ -162,7 +162,7 @@ fn read_until_after_read_to_end() {
162162 terminal. read_until ( "world" ) . unwrap ( ) ;
163163
164164 // Read everything else
165- terminal. read_to_end ( ) . unwrap ( ) ;
165+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
166166 let output = terminal. screen_contents ( ) ;
167167 assert ! ( output. contains( "hello world foo bar" ) ) ;
168168
@@ -195,7 +195,7 @@ fn write_basic_echo() {
195195
196196 // Read until we see the echo
197197 terminal. read_until ( "hello world" ) . unwrap ( ) ;
198- terminal. read_to_end ( ) . unwrap ( ) ;
198+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
199199
200200 let output = terminal. screen_contents ( ) ;
201201 // PTY echoes the input, so we see "hello world\nhello world"
@@ -231,7 +231,7 @@ fn write_multiple_lines() {
231231 terminal. write ( b"third\n " ) . unwrap ( ) ;
232232 terminal. read_until ( "Echo: third" ) . unwrap ( ) ;
233233
234- terminal. read_to_end ( ) . unwrap ( ) ;
234+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
235235 let output = terminal. screen_contents ( ) ;
236236 // PTY echoes input, so we see both the typed input and the echo response
237237 assert_eq ! ( output. trim( ) , "first\n Echo: firstsecond\n Echo: secondthird\n Echo: third" ) ;
@@ -247,7 +247,7 @@ fn write_after_exit() {
247247 let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
248248
249249 // Read all output - this blocks until child exits and EOF is reached
250- terminal. read_to_end ( ) . unwrap ( ) ;
250+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
251251
252252 // The background thread should have set writer to None by now
253253 // since read_to_end only returns after EOF (child exit)
@@ -282,7 +282,7 @@ fn write_interactive_prompt() {
282282 // Wait for greeting
283283 terminal. read_until ( "Hello, Alice" ) . unwrap ( ) ;
284284
285- terminal. read_to_end ( ) . unwrap ( ) ;
285+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
286286 let output = terminal. screen_contents ( ) ;
287287 assert_eq ! ( output. trim( ) , "Name: Alice\n Hello, Alice" ) ;
288288}
@@ -368,7 +368,7 @@ fn resize_terminal() {
368368 // Verify new size is correct
369369 terminal. read_until ( "resized: 40 40" ) . unwrap ( ) ;
370370
371- terminal. read_to_end ( ) . unwrap ( ) ;
371+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
372372}
373373
374374#[ test]
@@ -430,5 +430,31 @@ fn send_ctrl_c_interrupts_process() {
430430 // Verify interruption was detected
431431 terminal. read_until ( "INTERRUPTED" ) . unwrap ( ) ;
432432
433- terminal. read_to_end ( ) . unwrap ( ) ;
433+ let _ = terminal. read_to_end ( ) . unwrap ( ) ;
434+ }
435+
436+ #[ test]
437+ #[ timeout( 5000 ) ]
438+ fn read_to_end_returns_exit_status_success ( ) {
439+ let cmd = CommandBuilder :: from ( command_for_fn ! ( ( ) , |_: ( ) | {
440+ println!( "success" ) ;
441+ } ) ) ;
442+
443+ let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
444+ let status = terminal. read_to_end ( ) . unwrap ( ) ;
445+ assert ! ( status. success( ) ) ;
446+ assert_eq ! ( status. exit_code( ) , 0 ) ;
447+ }
448+
449+ #[ test]
450+ #[ timeout( 5000 ) ]
451+ fn read_to_end_returns_exit_status_nonzero ( ) {
452+ let cmd = CommandBuilder :: from ( command_for_fn ! ( ( ) , |_: ( ) | {
453+ std:: process:: exit( 42 ) ;
454+ } ) ) ;
455+
456+ let mut terminal = Terminal :: spawn ( ScreenSize { rows : 80 , cols : 80 } , cmd) . unwrap ( ) ;
457+ let status = terminal. read_to_end ( ) . unwrap ( ) ;
458+ assert ! ( !status. success( ) ) ;
459+ assert_eq ! ( status. exit_code( ) , 42 ) ;
434460}
0 commit comments