mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
24b20df7d5
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>
10 lines
160 B
Go
10 lines
160 B
Go
//go:build !windows
|
|
|
|
package ptytest
|
|
|
|
import "github.com/coder/coder/v2/pty"
|
|
|
|
func newTestPTY(opts ...pty.Option) (pty.PTY, error) {
|
|
return pty.New(opts...)
|
|
}
|