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 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-07-20 14:59:35 +02:00
parent f000ce9f1c
commit c217084c90

View file

@ -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()
}
}