Skip to content

Commit d8b0f20

Browse files
committed
resolve merge conficts
Signed-off-by: Maxim Zhiburt <[email protected]>
1 parent 2839cc7 commit d8b0f20

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/session.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,7 @@ impl<W: Write> StreamSession<W> {
7373

7474
// wrapper around reader::read_until to give more context for errors
7575
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)
8377
}
8478

8579
/// Make sure all bytes written via `send()` are sent to the process
@@ -107,11 +101,6 @@ impl<W: Write> StreamSession<W> {
107101
self.reader.try_read()
108102
}
109103

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-
115104
/// Wait until we see EOF (i.e. child process has terminated)
116105
/// Return all the yet unread output
117106
pub fn exp_eof(&mut self) -> Result<String> {
@@ -238,18 +227,11 @@ pub fn spawn(program: &str, timeout_ms: Option<u64>) -> Result<PtySession> {
238227
/// See `spawn`
239228
pub fn spawn_command(command: Command, timeout_ms: Option<u64>) -> Result<PtySession> {
240229
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")?;
242232
process.set_kill_timeout(timeout_ms);
243233

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)
253235
}
254236

255237
/// A repl session: e.g. bash or the python shell:
@@ -545,6 +527,7 @@ mod tests {
545527
Ok(())
546528
}()
547529
.unwrap_or_else(|e| panic!("test_expect_any failed: {}", e));
530+
}
548531

549532
#[test]
550533
fn test_expect_empty_command_error() {

0 commit comments

Comments
 (0)