popol
popol copied to clipboard
Prevent test_timeout from failing when a key is pressed
test_timeout() checks that the timeout parameter works by waiting on stdout to be ready for reading with a timeout of 1 ms. One might guess that stdout would never be ready for reading, but it appears that on macOS, at least, pressing enter while running the tests will cause stdout to be ready for reading, which in turn will cause the test to fail.
This switches test_timeout() to use UnixStream::pair() and just never write to the writer. This works even when keys are pressed while the tests are running.
Just got to say, stdout being ready for reading is super weird.
FWIW, I just confirmed the same behavior on Linux. ¯\_(ツ)_/¯