From 234fd6d72fbca16fcaf0b9f3995aa8e17e148ab7 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Sat, 23 Jul 2022 10:42:27 -0700 Subject: [PATCH] Revert "tests: alter integration tests for stdio to not use a handrolled cat implementation (#4803)" This reverts commit d8cad13fd92c4360031d5bac28514eebdf94ad1d. --- tests-integration/Cargo.toml | 2 -- tests-integration/src/bin/test-cat.rs | 24 +++++++++++++++--------- tests-integration/tests/process_stdio.rs | 14 ++------------ 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index d2dd5c9c335..82cdd4b24d6 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -7,7 +7,6 @@ publish = false [[bin]] name = "test-cat" -required-features = ["rt-process-io-util"] [[bin]] name = "test-mem" @@ -31,7 +30,6 @@ name = "rt_yield" required-features = ["rt", "macros", "sync"] [features] -rt-process-io-util = ["tokio/rt", "tokio/macros", "tokio/process", "tokio/io-util", "tokio/io-std"] # For mem check rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"] # For test-process-signal diff --git a/tests-integration/src/bin/test-cat.rs b/tests-integration/src/bin/test-cat.rs index 1e40c9d9d0d..3b30bf18a3c 100644 --- a/tests-integration/src/bin/test-cat.rs +++ b/tests-integration/src/bin/test-cat.rs @@ -1,14 +1,20 @@ //! A cat-like utility that can be used as a subprocess to test I/O //! stream communication. -use tokio::io::AsyncWriteExt; +use std::io; +use std::io::Write; -#[tokio::main(flavor = "current_thread")] -async fn main() { - let mut stdin = tokio::io::stdin(); - let mut stdout = tokio::io::stdout(); - - tokio::io::copy(&mut stdin, &mut stdout).await.unwrap(); - - stdout.flush().await.unwrap(); +fn main() { + let stdin = io::stdin(); + let mut stdout = io::stdout(); + let mut line = String::new(); + loop { + line.clear(); + stdin.read_line(&mut line).unwrap(); + if line.is_empty() { + break; + } + stdout.write_all(line.as_bytes()).unwrap(); + } + stdout.flush().unwrap(); } diff --git a/tests-integration/tests/process_stdio.rs b/tests-integration/tests/process_stdio.rs index 1ce41013ced..3f8ebfbfaa9 100644 --- a/tests-integration/tests/process_stdio.rs +++ b/tests-integration/tests/process_stdio.rs @@ -8,22 +8,12 @@ use tokio_test::assert_ok; use futures::future::{self, FutureExt}; use std::convert::TryInto; +use std::env; use std::io; use std::process::{ExitStatus, Stdio}; -// so, we need to change this back as a test, but for now this doesn't work because of: -// https://github.com/rust-lang/rust/pull/95469 -// -// undo when this is closed: https://github.com/tokio-rs/tokio/issues/4802 - -// fn cat() -> Command { -// let mut cmd = Command::new(std::env!("CARGO_BIN_EXE_test-cat")); -// cmd.stdin(Stdio::piped()).stdout(Stdio::piped()); -// cmd -// } - fn cat() -> Command { - let mut cmd = Command::new("cat"); + let mut cmd = Command::new(env!("CARGO_BIN_EXE_test-cat")); cmd.stdin(Stdio::piped()).stdout(Stdio::piped()); cmd }