diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-02-22 17:02:12 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-02-23 02:44:18 -0500 |
commit | 39287b07f87aba15c4cb0f64d7008ba67289151d (patch) | |
tree | a0ce5fee6e98a7c429f668000d7cdc71cf8d4797 /tests/helpers | |
parent | ebcf5f15081f6a84c861eb2aecbf962396a88695 (diff) | |
download | pty-process-39287b07f87aba15c4cb0f64d7008ba67289151d.tar.gz pty-process-39287b07f87aba15c4cb0f64d7008ba67289151d.zip |
another rewrite
Diffstat (limited to 'tests/helpers')
-rw-r--r-- | tests/helpers/mod.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 4fee8df..a46a12b 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -31,23 +31,20 @@ pub fn output(pty: &pty_process::blocking::Pty) -> Output<'_> { } #[cfg(feature = "async")] -pub fn output_async( - pty: &pty_process::Pty, -) -> std::pin::Pin<Box<dyn futures::stream::Stream<Item = String> + '_>> { - use async_std::io::prelude::BufReadExt as _; +pub fn output_async<'a>( + pty: impl tokio::io::AsyncRead + std::marker::Unpin + 'a, +) -> std::pin::Pin<Box<dyn futures::stream::Stream<Item = String> + 'a>> { use futures::FutureExt as _; + use tokio::io::AsyncBufReadExt as _; - let pty = async_std::io::BufReader::new(pty); + let pty = tokio::io::BufReader::new(pty); Box::pin(futures::stream::unfold(pty, |mut pty| async move { Some(( - async_std::future::timeout( - std::time::Duration::from_secs(5), - async { - let mut buf = vec![]; - pty.read_until(b'\n', &mut buf).await.unwrap(); - std::string::String::from_utf8(buf).unwrap() - }, - ) + tokio::time::timeout(std::time::Duration::from_secs(5), async { + let mut buf = vec![]; + pty.read_until(b'\n', &mut buf).await.unwrap(); + std::string::String::from_utf8(buf).unwrap() + }) .map(|x| x.unwrap()) .await, pty, |