From b2733e64d900ac237211360848326f3c4caa23f5 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 27 Feb 2022 17:37:03 -0500 Subject: simplify --- tests/winch.rs | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'tests/winch.rs') diff --git a/tests/winch.rs b/tests/winch.rs index 6b16ca9..63455e9 100644 --- a/tests/winch.rs +++ b/tests/winch.rs @@ -27,36 +27,31 @@ fn test_winch_std() { } #[cfg(feature = "async")] +#[tokio::main] #[test] -fn test_winch_async() { +async fn test_winch_async() { use futures::stream::StreamExt as _; 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(&pts) - .unwrap(); - - 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_w.resize(pty_process::Size::new(25, 80)).unwrap(); - assert_eq!(output.next().await.unwrap(), "WINCH\r\n"); - - pty_w.write_all(b"\n").await.unwrap(); - child.wait().await.unwrap() - }); + 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(&pts) + .unwrap(); + + 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_w.resize(pty_process::Size::new(25, 80)).unwrap(); + assert_eq!(output.next().await.unwrap(), "WINCH\r\n"); + + pty_w.write_all(b"\n").await.unwrap(); + let status = child.wait().await.unwrap(); assert_eq!(status.code().unwrap(), 0); } -- cgit v1.2.3-54-g00ecf