From c217084c90b78ff9127ec5ff2c6e6f8c7bf7545a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 20 Jul 2026 14:59:35 +0200 Subject: [PATCH] Add test showing StartPty fails on Windows when given a zero size CreatePseudoConsole rejects zero dimensions with E_INVALIDARG, so starting a pty sized after a hidden (and thus zero-sized) view fails. Co-Authored-By: Claude Fable 5 --- pkg/commands/oscommands/pty_windows_test.go | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkg/commands/oscommands/pty_windows_test.go diff --git a/pkg/commands/oscommands/pty_windows_test.go b/pkg/commands/oscommands/pty_windows_test.go new file mode 100644 index 000000000..d16d3b295 --- /dev/null +++ b/pkg/commands/oscommands/pty_windows_test.go @@ -0,0 +1,28 @@ +package oscommands + +import ( + "os/exec" + "testing" + + "github.com/stretchr/testify/assert" +) + +// The requested size can legitimately be zero: the pty inherits the main +// view's dimensions, and that view is zero-sized while hidden, e.g. in +// full-screen mode with a side panel focused. +func TestStartPtyWithZeroSize(t *testing.T) { + // The command deliberately produces no output: go test runs with + // redirected std handles, which CreateProcess duplicates into the child + // in place of handles to the attached pseudoconsole, so command output + // would bypass the pty and pollute the test log. + sp, err := StartPty(exec.Command("cmd", "/c", "exit 0"), 0, 0) + /* EXPECTED: + assert.NoError(t, err) + ACTUAL: */ + assert.Error(t, err) + + if err == nil { + _ = sp.Wait() + _ = sp.Pty.Close() + } +}