tokio
tokio copied to clipboard
io: always forward flush to stdout and stderr
Always call flush on the inner IO resource even if nothing has been written. This is necessary because someone could have written to stdout or stderr via some other object, and that data would go into the same shared buffer.
Closes: #4347
I'm not sure how we can actually test it. We can assert that the write and flush succeeds, but we can't look at what actually got written.
Ah, it's indeed not easy to test it.
I think we can test this by adding the #4347's code to tests-integration/src/bin and doing something similar to the following shell script.
cargo run >tmp &
kill $!
grep <tmp "What's your name?: "
However, it is more complex and tricky than what I had imagined during the initial review, so I'm okay with merging this without adding a test.
It appears that the integration test keeps failing on Mac OS. Any ideas?