@@ -73,13 +73,7 @@ impl<W: Write> StreamSession<W> {
73
73
74
74
// wrapper around reader::read_until to give more context for errors
75
75
pub fn exp < N : Needle + std:: fmt:: Display + ?Sized > ( & mut self , needle : & N ) -> Result < N :: Interest > {
76
- match self . reader . read_until ( needle) {
77
- Ok ( s) => Ok ( s) ,
78
- Err ( Error ( ErrorKind :: EOF ( expected, got, _) , _) ) => {
79
- Err ( ErrorKind :: EOF ( expected, got, self . process . status ( ) ) . into ( ) )
80
- }
81
- Err ( e) => Err ( e) ,
82
- }
76
+ self . reader . read_until ( needle)
83
77
}
84
78
85
79
/// Make sure all bytes written via `send()` are sent to the process
@@ -107,11 +101,6 @@ impl<W: Write> StreamSession<W> {
107
101
self . reader . try_read ( )
108
102
}
109
103
110
- // wrapper around reader::read_until to give more context for errors
111
- fn exp ( & mut self , needle : & ReadUntil ) -> Result < ( String , String ) > {
112
- self . reader . read_until ( needle)
113
- }
114
-
115
104
/// Wait until we see EOF (i.e. child process has terminated)
116
105
/// Return all the yet unread output
117
106
pub fn exp_eof ( & mut self ) -> Result < String > {
@@ -238,18 +227,11 @@ pub fn spawn(program: &str, timeout_ms: Option<u64>) -> Result<PtySession> {
238
227
/// See `spawn`
239
228
pub fn spawn_command ( command : Command , timeout_ms : Option < u64 > ) -> Result < PtySession > {
240
229
let commandname = format ! ( "{:?}" , & command) ;
241
- let mut process = PtyProcess :: new ( command) . chain_err ( || "couldn't start process" ) ?;
230
+ let mut process = PtyProcess :: new ( command)
231
+ . chain_err ( || "couldn't start process" ) ?;
242
232
process. set_kill_timeout ( timeout_ms) ;
243
233
244
- let f = process. get_file_handle ( ) ;
245
- let writer = LineWriter :: new ( f. try_clone ( ) . chain_err ( || "couldn't open write stream" ) ?) ;
246
- let reader = NBReader :: new ( f, timeout_ms) ;
247
- Ok ( PtySession {
248
- process : process,
249
- writer : writer,
250
- reader : reader,
251
- commandname : commandname,
252
- } )
234
+ PtySession :: new ( process, timeout_ms, commandname)
253
235
}
254
236
255
237
/// A repl session: e.g. bash or the python shell:
@@ -545,6 +527,7 @@ mod tests {
545
527
Ok ( ( ) )
546
528
} ( )
547
529
. unwrap_or_else ( |e| panic ! ( "test_expect_any failed: {}" , e) ) ;
530
+ }
548
531
549
532
#[ test]
550
533
fn test_expect_empty_command_error ( ) {
0 commit comments