mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
Revert "tests: alter integration tests for stdio to not use a handrolled cat implementation (#4803)" (#4854)
This reverts commit d8cad13fd9.
This commit is contained in:
@@ -7,7 +7,6 @@ publish = false
|
|||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "test-cat"
|
name = "test-cat"
|
||||||
required-features = ["rt-process-io-util"]
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "test-mem"
|
name = "test-mem"
|
||||||
@@ -31,7 +30,6 @@ name = "rt_yield"
|
|||||||
required-features = ["rt", "macros", "sync"]
|
required-features = ["rt", "macros", "sync"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
rt-process-io-util = ["tokio/rt", "tokio/macros", "tokio/process", "tokio/io-util", "tokio/io-std"]
|
|
||||||
# For mem check
|
# For mem check
|
||||||
rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"]
|
rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"]
|
||||||
# For test-process-signal
|
# For test-process-signal
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
//! A cat-like utility that can be used as a subprocess to test I/O
|
//! A cat-like utility that can be used as a subprocess to test I/O
|
||||||
//! stream communication.
|
//! stream communication.
|
||||||
|
|
||||||
use tokio::io::AsyncWriteExt;
|
use std::io;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
fn main() {
|
||||||
async fn main() {
|
let stdin = io::stdin();
|
||||||
let mut stdin = tokio::io::stdin();
|
let mut stdout = io::stdout();
|
||||||
let mut stdout = tokio::io::stdout();
|
let mut line = String::new();
|
||||||
|
loop {
|
||||||
tokio::io::copy(&mut stdin, &mut stdout).await.unwrap();
|
line.clear();
|
||||||
|
stdin.read_line(&mut line).unwrap();
|
||||||
stdout.flush().await.unwrap();
|
if line.is_empty() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
stdout.write_all(line.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
stdout.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,12 @@ use tokio_test::assert_ok;
|
|||||||
|
|
||||||
use futures::future::{self, FutureExt};
|
use futures::future::{self, FutureExt};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
use std::env;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::process::{ExitStatus, Stdio};
|
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 {
|
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.stdin(Stdio::piped()).stdout(Stdio::piped());
|
||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user