Skip to content

Commit 94a7eae

Browse files
authored
Revert "tests: alter integration tests for stdio to not use a handrolled cat implementation (#4803)" (#4854)
This reverts commit d8cad13.
1 parent 62593be commit 94a7eae

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

tests-integration/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ publish = false
77

88
[[bin]]
99
name = "test-cat"
10-
required-features = ["rt-process-io-util"]
1110

1211
[[bin]]
1312
name = "test-mem"
@@ -31,7 +30,6 @@ name = "rt_yield"
3130
required-features = ["rt", "macros", "sync"]
3231

3332
[features]
34-
rt-process-io-util = ["tokio/rt", "tokio/macros", "tokio/process", "tokio/io-util", "tokio/io-std"]
3533
# For mem check
3634
rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"]
3735
# For test-process-signal

tests-integration/src/bin/test-cat.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
//! A cat-like utility that can be used as a subprocess to test I/O
22
//! stream communication.
33
4-
use tokio::io::AsyncWriteExt;
4+
use std::io;
5+
use std::io::Write;
56

6-
#[tokio::main(flavor = "current_thread")]
7-
async fn main() {
8-
let mut stdin = tokio::io::stdin();
9-
let mut stdout = tokio::io::stdout();
10-
11-
tokio::io::copy(&mut stdin, &mut stdout).await.unwrap();
12-
13-
stdout.flush().await.unwrap();
7+
fn main() {
8+
let stdin = io::stdin();
9+
let mut stdout = io::stdout();
10+
let mut line = String::new();
11+
loop {
12+
line.clear();
13+
stdin.read_line(&mut line).unwrap();
14+
if line.is_empty() {
15+
break;
16+
}
17+
stdout.write_all(line.as_bytes()).unwrap();
18+
}
19+
stdout.flush().unwrap();
1420
}

tests-integration/tests/process_stdio.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,12 @@ use tokio_test::assert_ok;
88

99
use futures::future::{self, FutureExt};
1010
use std::convert::TryInto;
11+
use std::env;
1112
use std::io;
1213
use std::process::{ExitStatus, Stdio};
1314

14-
// so, we need to change this back as a test, but for now this doesn't work because of:
15-
// https://github.com/rust-lang/rust/pull/95469
16-
//
17-
// undo when this is closed: https://github.com/tokio-rs/tokio/issues/4802
18-
19-
// fn cat() -> Command {
20-
// let mut cmd = Command::new(std::env!("CARGO_BIN_EXE_test-cat"));
21-
// cmd.stdin(Stdio::piped()).stdout(Stdio::piped());
22-
// cmd
23-
// }
24-
2515
fn cat() -> Command {
26-
let mut cmd = Command::new("cat");
16+
let mut cmd = Command::new(env!("CARGO_BIN_EXE_test-cat"));
2717
cmd.stdin(Stdio::piped()).stdout(Stdio::piped());
2818
cmd
2919
}

0 commit comments

Comments
 (0)