aboutsummaryrefslogtreecommitdiffstats
path: root/tests/winch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/winch.rs')
-rw-r--r--tests/winch.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/tests/winch.rs b/tests/winch.rs
index 50447cb..6b16ca9 100644
--- a/tests/winch.rs
+++ b/tests/winch.rs
@@ -4,14 +4,15 @@ mod helpers;
fn test_winch_std() {
use std::io::Write as _;
- let pty = pty_process::blocking::Pty::new().unwrap();
+ let mut pty = pty_process::blocking::Pty::new().unwrap();
+ let pts = pty.pts().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(&pts)
.unwrap();
let mut output = helpers::output(&pty);
@@ -20,7 +21,7 @@ fn test_winch_std() {
pty.resize(pty_process::Size::new(25, 80)).unwrap();
assert_eq!(output.next().unwrap(), "WINCH\r\n");
- (&pty).write_all(b"\n").unwrap();
+ pty.write_all(b"\n").unwrap();
let status = child.wait().unwrap();
assert_eq!(status.code().unwrap(), 0);
}
@@ -28,28 +29,34 @@ fn test_winch_std() {
#[cfg(feature = "async")]
#[test]
fn test_winch_async() {
- use async_std::io::prelude::WriteExt as _;
use futures::stream::StreamExt as _;
-
- let status = async_std::task::block_on(async {
- let pty = pty_process::Pty::new().unwrap();
- pty.resize(pty_process::Size::new(24, 80)).unwrap();
- let mut child = pty_process::Command::new("perl")
+ use tokio::io::AsyncWriteExt as _;
+
+ let status = tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()
+ .unwrap()
+ .block_on(async {
+ let mut pty = pty_process::Pty::new().unwrap();
+ let pts = pty.pts().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(&pts)
.unwrap();
- let mut output = helpers::output_async(&pty);
- assert_eq!(output.next().await.unwrap(), "started\r\n");
+ let (pty_r, mut pty_w) = pty.split();
+ let mut output = helpers::output_async(pty_r);
+ assert_eq!(output.next().await.unwrap(), "started\r\n");
- pty.resize(pty_process::Size::new(25, 80)).unwrap();
- assert_eq!(output.next().await.unwrap(), "WINCH\r\n");
+ pty_w.resize(pty_process::Size::new(25, 80)).unwrap();
+ assert_eq!(output.next().await.unwrap(), "WINCH\r\n");
- (&pty).write_all(b"\n").await.unwrap();
- child.status().await.unwrap()
- });
+ pty_w.write_all(b"\n").await.unwrap();
+ child.wait().await.unwrap()
+ });
assert_eq!(status.code().unwrap(), 0);
}