From e6f2326e77a7aa60b2c7e0fa77fe1b2a3c2a3af5 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Wed, 11 Nov 2026 19:54:01 +0000 Subject: [PATCH] termtest: deliver the prompt result before closing the stdin pipe On Windows, bubbletea cannot cancel a read on a pipe, so closing the read end could block until the test closed the write end in cleanup, after Result had already timed out. Co-authored-by: Isaac --- libs/cmdio/cmdiotest/termtest/termtest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/cmdio/cmdiotest/termtest/termtest.go b/libs/cmdio/cmdiotest/termtest/termtest.go index 6ef0a71df09..034ac35a0f8 100644 --- a/libs/cmdio/cmdiotest/termtest/termtest.go +++ b/libs/cmdio/cmdiotest/termtest/termtest.go @@ -182,8 +182,12 @@ func Run[T any](t *testing.T, fn func(ctx context.Context) (T, error)) *Term[T] ctx := cmdio.InContext(t.Context(), io) go func() { v, err := fn(ctx) - _ = inR.Close() tt.done <- resultMsg[T]{value: v, err: err} + // Deliver the result before closing inR: on Windows bubbletea cannot + // cancel a read on a pipe, so its read loop can stay blocked in + // ReadFile on inR and inR.Close waits for that read until Close + // closes inW. + _ = inR.Close() close(tt.finished) }() t.Cleanup(tt.Close)