tokio icon indicating copy to clipboard operation
tokio copied to clipboard

io: always forward flush to stdout and stderr

Open Darksonn opened this issue 2 years ago • 3 comments

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

Darksonn avatar Dec 27 '21 11:12 Darksonn

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.

Darksonn avatar Dec 27 '21 15:12 Darksonn

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.

taiki-e avatar Dec 27 '21 16:12 taiki-e

It appears that the integration test keeps failing on Mac OS. Any ideas?

Darksonn avatar Dec 30 '21 14:12 Darksonn