aboutsummaryrefslogtreecommitdiffstats
path: root/tests/winch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/winch.rs')
-rw-r--r--tests/winch.rs46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/winch.rs b/tests/winch.rs
index 9d26751..40ffaf4 100644
--- a/tests/winch.rs
+++ b/tests/winch.rs
@@ -2,26 +2,26 @@
fn test_winch_std() {
use std::io::{Read as _, Write as _};
- let pty = pty_process::blocking::Pty::new().unwrap();
+ let mut pty = pty_process::blocking::Pty::new().unwrap();
pty.resize(pty_process::Size::new(24, 80)).unwrap();
let mut child = pty_process::blocking::Command::new("perl")
.args(&[
"-E",
"$|++; $SIG{WINCH} = sub { say 'WINCH' }; say 'started'; <>",
])
- .spawn(pty)
+ .spawn(&pty)
.unwrap();
let mut buf = [0u8; 1024];
- let bytes = child.pty().read(&mut buf).unwrap();
+ let bytes = pty.read(&mut buf).unwrap();
assert_eq!(&buf[..bytes], b"started\r\n");
- child.pty().resize(pty_process::Size::new(25, 80)).unwrap();
+ pty.resize(pty_process::Size::new(25, 80)).unwrap();
- let bytes = child.pty().read(&mut buf).unwrap();
+ let bytes = pty.read(&mut buf).unwrap();
assert_eq!(&buf[..bytes], b"WINCH\r\n");
- child.pty().write_all(b"\n").unwrap();
+ pty.write_all(b"\n").unwrap();
let status = child.wait().unwrap();
assert_eq!(status.code().unwrap(), 0);
}
@@ -33,26 +33,26 @@ fn test_winch_async_std() {
use async_std::io::ReadExt as _;
let status = async_std::task::block_on(async {
- let pty = pty_process::Pty::new().unwrap();
+ let mut pty = pty_process::Pty::new().unwrap();
pty.resize(pty_process::Size::new(24, 80)).unwrap();
let mut child = pty_process::Command::new("perl")
.args(&[
"-E",
"$|++; $SIG{WINCH} = sub { say 'WINCH' }; say 'started'; <>",
])
- .spawn(pty)
+ .spawn(&pty)
.unwrap();
let mut buf = [0u8; 1024];
- let bytes = child.pty().read(&mut buf).await.unwrap();
+ let bytes = pty.read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"started\r\n");
- child.pty().resize(pty_process::Size::new(25, 80)).unwrap();
+ pty.resize(pty_process::Size::new(25, 80)).unwrap();
- let bytes = child.pty().read(&mut buf).await.unwrap();
+ let bytes = pty.read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"WINCH\r\n");
- child.pty().write_all(b"\n").await.unwrap();
+ pty.write_all(b"\n").await.unwrap();
child.status().await.unwrap()
});
assert_eq!(status.code().unwrap(), 0);
@@ -64,26 +64,26 @@ fn test_winch_smol() {
use smol::io::{AsyncReadExt as _, AsyncWriteExt as _};
let status = smol::block_on(async {
- let pty = pty_process::Pty::new().unwrap();
+ let mut pty = pty_process::Pty::new().unwrap();
pty.resize(pty_process::Size::new(24, 80)).unwrap();
let mut child = pty_process::Command::new("perl")
.args(&[
"-E",
"$|++; $SIG{WINCH} = sub { say 'WINCH' }; say 'started'; <>",
])
- .spawn(pty)
+ .spawn(&pty)
.unwrap();
let mut buf = [0u8; 1024];
- let bytes = child.pty().read(&mut buf).await.unwrap();
+ let bytes = pty.read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"started\r\n");
- child.pty().resize(pty_process::Size::new(25, 80)).unwrap();
+ pty.resize(pty_process::Size::new(25, 80)).unwrap();
- let bytes = child.pty().read(&mut buf).await.unwrap();
+ let bytes = pty.read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"WINCH\r\n");
- child.pty().write_all(b"\n").await.unwrap();
+ pty.write_all(b"\n").await.unwrap();
child.status().await.unwrap()
});
assert_eq!(status.code().unwrap(), 0);
@@ -103,19 +103,19 @@ fn test_winch_tokio() {
"-E",
"$|++; $SIG{WINCH} = sub { say 'WINCH' }; say 'started'; <>",
])
- .spawn(pty)
+ .spawn(&pty)
.unwrap();
let mut buf = [0u8; 1024];
- let bytes = child.pty().compat().read(&mut buf).await.unwrap();
+ let bytes = pty.compat().read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"started\r\n");
- child.pty().resize(pty_process::Size::new(25, 80)).unwrap();
+ pty.resize(pty_process::Size::new(25, 80)).unwrap();
- let bytes = child.pty().compat().read(&mut buf).await.unwrap();
+ let bytes = pty.compat().read(&mut buf).await.unwrap();
assert_eq!(&buf[..bytes], b"WINCH\r\n");
- child.pty().compat().write_all(b"\n").await.unwrap();
+ pty.compat().write_all(b"\n").await.unwrap();
child.status().await.unwrap()
}
tokio::runtime::Runtime::new().unwrap().block_on(async {