Skip to content

Commit

Permalink
resolve merge conficts
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Zhiburt <[email protected]>
  • Loading branch information
zhiburt committed Jun 7, 2020
1 parent 2839cc7 commit d8b0f20
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ impl<W: Write> StreamSession<W> {

// wrapper around reader::read_until to give more context for errors
pub fn exp<N: Needle + std::fmt::Display + ?Sized>(&mut self, needle: &N) -> Result<N::Interest> {
match self.reader.read_until(needle) {
Ok(s) => Ok(s),
Err(Error(ErrorKind::EOF(expected, got, _), _)) => {
Err(ErrorKind::EOF(expected, got, self.process.status()).into())
}
Err(e) => Err(e),
}
self.reader.read_until(needle)
}

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

// wrapper around reader::read_until to give more context for errors
fn exp(&mut self, needle: &ReadUntil) -> Result<(String, String)> {
self.reader.read_until(needle)
}

/// Wait until we see EOF (i.e. child process has terminated)
/// Return all the yet unread output
pub fn exp_eof(&mut self) -> Result<String> {
Expand Down Expand Up @@ -238,18 +227,11 @@ pub fn spawn(program: &str, timeout_ms: Option<u64>) -> Result<PtySession> {
/// See `spawn`
pub fn spawn_command(command: Command, timeout_ms: Option<u64>) -> Result<PtySession> {
let commandname = format!("{:?}", &command);
let mut process = PtyProcess::new(command).chain_err(|| "couldn't start process")?;
let mut process = PtyProcess::new(command)
.chain_err(|| "couldn't start process")?;
process.set_kill_timeout(timeout_ms);

let f = process.get_file_handle();
let writer = LineWriter::new(f.try_clone().chain_err(|| "couldn't open write stream")?);
let reader = NBReader::new(f, timeout_ms);
Ok(PtySession {
process: process,
writer: writer,
reader: reader,
commandname: commandname,
})
PtySession::new(process, timeout_ms, commandname)
}

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

#[test]
fn test_expect_empty_command_error() {
Expand Down

0 comments on commit d8b0f20

Please sign in to comment.