mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix: use os.Pipe implementation for Windows CLI tests to reduce flakiness (#21874)
On Windows, `pty.New()` was creating a `ConPTY` (`PseudoConsole`) even when no process would be attached. `ConPTY` requires a real process to function correctly - without one, the pipe handles become invalid intermittently, causing flaky test failures like `read |0: The handle is invalid.` This affected tests using the `ptytest.New()` + `Attach()` pattern for in-process CLI testing. The fix splits Windows PTY creation into two paths: - `newPty()` now returns a simple pipe-based PTY for the `Attach()` use case - `newConPty()` creates a real `ConPTY`, called by `Start()` when a process will be attached AFAICT this will result in no change in behaviour outside of tests. Fixes coder/internal#1277 _Disclaimer: investigated and implemented by Claude Opus 4.5, reviewed by me._ --------- Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
func New(t *testing.T, opts ...pty.Option) *PTY {
|
||||
t.Helper()
|
||||
|
||||
ptty, err := pty.New(opts...)
|
||||
ptty, err := newTestPTY(opts...)
|
||||
require.NoError(t, err)
|
||||
|
||||
e := newExpecter(t, ptty.Output(), "cmd")
|
||||
|
||||
Reference in New Issue
Block a user