From 6eee04158c09d44efa7087f278cd41cc5aebf0e1 Mon Sep 17 00:00:00 2001 From: Hamir Date: Fri, 7 Aug 2026 15:20:11 -0700 Subject: [PATCH 1/3] fix: flaky `TestPrunePromptTermination` test --- internal/test/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/test/cmd.go b/internal/test/cmd.go index 8b98d2df623b..1ac066bd356d 100644 --- a/internal/test/cmd.go +++ b/internal/test/cmd.go @@ -27,8 +27,11 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli })) cli.SetOut(outStream) - r, _, err := os.Pipe() + r, w, err := os.Pipe() assert.NilError(t, err) + + // Keep the write end alive for the duration of the test. + defer w.Close() cli.SetIn(streams.NewIn(r)) notifyCtx, notifyCancel := context.WithCancel(ctx) From 3ea231bfbace2e225ef615210a2859aafe964935 Mon Sep 17 00:00:00 2001 From: Hamir Date: Mon, 19 Oct 2026 09:28:40 -0700 Subject: [PATCH 2/3] drop `OutBuffer()` checks that are now unnecessary --- cmd/docker-trust/internal/test/cmd.go | 2 -- internal/test/cmd.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/cmd/docker-trust/internal/test/cmd.go b/cmd/docker-trust/internal/test/cmd.go index 8b98d2df623b..4da52c5f4f4c 100644 --- a/cmd/docker-trust/internal/test/cmd.go +++ b/cmd/docker-trust/internal/test/cmd.go @@ -58,8 +58,6 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli }() } - assert.Check(t, cli.OutBuffer().Len() > 0) - // a small delay to ensure the plugin is prompting time.Sleep(100 * time.Microsecond) diff --git a/internal/test/cmd.go b/internal/test/cmd.go index 1ac066bd356d..f3d36b69e5b8 100644 --- a/internal/test/cmd.go +++ b/internal/test/cmd.go @@ -61,8 +61,6 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli }() } - assert.Check(t, cli.OutBuffer().Len() > 0) - // a small delay to ensure the plugin is prompting time.Sleep(100 * time.Microsecond) From 3f83a0c96e6f88c4ca3586c6962dab635d4c8a53 Mon Sep 17 00:00:00 2001 From: Hamir Date: Mon, 19 Oct 2026 09:29:32 -0700 Subject: [PATCH 3/3] fix identical issue in `internal/test/cmd.go` --- cmd/docker-trust/internal/test/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/docker-trust/internal/test/cmd.go b/cmd/docker-trust/internal/test/cmd.go index 4da52c5f4f4c..f3d36b69e5b8 100644 --- a/cmd/docker-trust/internal/test/cmd.go +++ b/cmd/docker-trust/internal/test/cmd.go @@ -27,8 +27,11 @@ func TerminatePrompt(ctx context.Context, t *testing.T, cmd *cobra.Command, cli })) cli.SetOut(outStream) - r, _, err := os.Pipe() + r, w, err := os.Pipe() assert.NilError(t, err) + + // Keep the write end alive for the duration of the test. + defer w.Close() cli.SetIn(streams.NewIn(r)) notifyCtx, notifyCancel := context.WithCancel(ctx)