Unless ptytest output is consumed, a test can hang if a command outputs more than 1024 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 using ptytest 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 for ptytest to buffer/consume all command output, irregardless of a call to ExpectMatch.
A reproduction of this bug exists as a test in #1629 (and will be merged in and skipped on macOS and Windows).