@@ -307,3 +307,28 @@ func TestBackgroundShellManager_KillAll_Timeout(t *testing.T) {
307307 // Must return promptly after timeout, not hang for 60 seconds.
308308 require.Less(t, elapsed, 2*time.Second)
309309}
310+
311+func TestBackgroundShell_WaitContext_Completed(t *testing.T) {
312+ t.Parallel()
313+
314+ done := make(chan struct{})
315+ close(done)
316+
317+ bgShell := &BackgroundShell{done: done}
318+
319+ ctx, cancel := context.WithTimeout(t.Context(), time.Second)
320+ t.Cleanup(cancel)
321+
322+ require.True(t, bgShell.WaitContext(ctx))
323+}
324+
325+func TestBackgroundShell_WaitContext_Canceled(t *testing.T) {
326+ t.Parallel()
327+
328+ bgShell := &BackgroundShell{done: make(chan struct{})}
329+
330+ ctx, cancel := context.WithCancel(t.Context())
331+ cancel()
332+
333+ require.False(t, bgShell.WaitContext(ctx))
334+}