- Notifications
You must be signed in to change notification settings - Fork928
Closed
Description
Unlessptytest
output is consumed, a test can hang if a command outputs more than1024
bytes (at least on macOS).
There are two ways to work around this issue:
- Consume the output via
pty.ExpectMatch()
(ensure no more than 1024 bytes are left unread) - Use
cmd.SetOut(io.Discard)
instead
Since usingptytest
is a common pattern in our tests, it'd be a good idea to rewrite it so that a hang is not possible.
Unless there's a bug to be fixed in underlying libraries, or changes to how ptys are configured, the most robust way to fix this would be forptytest
to buffer/consumeall command output, irregardless of a call toExpectMatch
.
A reproduction of this bug exists as a test in#1629 (and will be merged in and skipped on macOS and Windows).