-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: alter integration tests for stdio to not use a handrolled cat …
…implementation (#4803) This fixes #4801, where, as a result of rust-lang/rust#95469, our implementation of cat used for this test no longer works, as stdio functions on windows now can abort the process if the pipe is set to nonblocking mode. Unfortunately in windows, setting one end of the pipe to be nonblocking makes the whole thing nonblocking, so when, in tokio::process we set the child pipes to nonblocking mode, it causes serious problems for any rust program at the other end. Fixing this issue is for another day, but fixing the tests is for today.
- Loading branch information
1 parent
8ed06ef
commit d8cad13
Showing
3 changed files
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
//! A cat-like utility that can be used as a subprocess to test I/O | ||
//! stream communication. | ||
|
||
use std::io; | ||
use std::io::Write; | ||
use tokio::io::AsyncWriteExt; | ||
|
||
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(); | ||
#[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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters