Skip to content

fix: replace Go PTY tests with txtar using creack/pty#2682

Merged
michaeldwan merged 2 commits intomainfrom
md/fix-interactive-tty-test
Feb 4, 2026
Merged

fix: replace Go PTY tests with txtar using creack/pty#2682
michaeldwan merged 2 commits intomainfrom
md/fix-interactive-tty-test

Conversation

@michaeldwan
Copy link
Copy Markdown
Member

Summary

  • Replace flaky Go-based PTY tests with txtar tests using creack/pty
  • Add pty-run testscript command for PTY interaction in txtar tests
  • Fix macOS hanging issue caused by Go bug #61779

Problem

The TestInteractiveTTY test was flaky on macOS because testscript's native ttyin/ttyout uses Go's setctty syscall which hangs due to Go bug #61779. This bug affects macOS and causes cmd.Wait() to hang indefinitely when using SysProcAttr.Setctty.

Solution

Replace the Go-based PTY tests with txtar tests using a new pty-run command that uses github.com/creack/pty, which works correctly on both Linux and macOS.

Changes

  • New pty-run command (integration-tests/harness/cmd_pty.go): Executes commands with a PTY, sending input from a file and capturing output
  • Command interface (integration-tests/harness/command.go): Cleaner organization for testscript commands
  • New txtar tests: pty_echo.txtar and pty_interactive.txtar
  • Removed: integration-tests/pty/pty_test.go (replaced by txtar tests)
  • Updated README: Documented the new pty-run command

Testing

Both tests pass locally on macOS:

=== RUN   TestIntegration/pty_echo
--- PASS: TestIntegration/pty_echo (6.06s)
=== RUN   TestIntegration/pty_interactive  
--- PASS: TestIntegration/pty_interactive (6.39s)

Future

Added a TODO to remove this implementation once Go bug #61779 is fixed (check Go 1.26+).

The TestInteractiveTTY test was flaky on macOS because testscript's
native ttyin/ttyout uses Go's setctty syscall which hangs due to
Go bug golang/go#61779.

This replaces the Go-based PTY tests with txtar tests using the new
pty-run command, which uses github.com/creack/pty that works correctly
on both Linux and macOS.

Changes:
- Add pty-run testscript command using creack/pty
- Add Command interface for cleaner command organization
- Convert PTY tests to txtar format (pty_echo, pty_interactive)
- Remove old Go-based pty/pty_test.go
- Update README with pty-run documentation
@michaeldwan michaeldwan requested a review from a team as a code owner February 4, 2026 20:01
@michaeldwan michaeldwan merged commit f0cb3ec into main Feb 4, 2026
16 checks passed
@michaeldwan michaeldwan deleted the md/fix-interactive-tty-test branch February 4, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants