aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/basic.rs b/tests/basic.rs
index 6f276e6..ed75e60 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -51,3 +51,36 @@ fn test_cat_async() {
});
assert_eq!(status.code().unwrap(), 0);
}
+
+#[cfg(feature = "async")]
+#[test]
+fn test_yes_async() {
+ use tokio::io::AsyncReadExt as _;
+
+ 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("yes").spawn(&pts).unwrap();
+
+ let mut buf = [0u8; 3];
+
+ let bytes = pty.read_buf(&mut &mut buf[..]).await.unwrap();
+ assert_eq!(&buf[..bytes], b"y\r\n");
+
+ let (mut pty_r, _pty_w) = pty.split();
+ let bytes = pty_r.read_buf(&mut &mut buf[..]).await.unwrap();
+ assert_eq!(&buf[..bytes], b"y\r\n");
+
+ let (mut pty_r, _pty_w) = pty.into_split();
+ let bytes = pty_r.read_buf(&mut &mut buf[..]).await.unwrap();
+ assert_eq!(&buf[..bytes], b"y\r\n");
+
+ child.kill().await.unwrap()
+ });
+}