@@ -14,7 +14,7 @@ func TestBackgroundShellManager_Start(t *testing.T) {
14 t.Skip("Skipping this until I figure out why its flaky")
14 t.Skip("Skipping this until I figure out why its flaky")
15 t.Parallel()
15 t.Parallel()
17− ctx := context.Background()
17+ ctx := t.Context()
18 workingDir := t.TempDir()
18 workingDir := t.TempDir()
19 manager := newBackgroundShellManager()
19 manager := newBackgroundShellManager()
@@ -51,7 +51,7 @@ func TestBackgroundShellManager_Start(t *testing.T) {
51func TestBackgroundShellManager_Get(t *testing.T) {
51func TestBackgroundShellManager_Get(t *testing.T) {
52 t.Parallel()
52 t.Parallel()
54− ctx := context.Background()
54+ ctx := t.Context()
55 workingDir := t.TempDir()
55 workingDir := t.TempDir()
56 manager := newBackgroundShellManager()
56 manager := newBackgroundShellManager()
@@ -77,7 +77,7 @@ func TestBackgroundShellManager_Get(t *testing.T) {
77func TestBackgroundShellManager_Kill(t *testing.T) {
77func TestBackgroundShellManager_Kill(t *testing.T) {
78 t.Parallel()
78 t.Parallel()
80− ctx := context.Background()
80+ ctx := t.Context()
81 workingDir := t.TempDir()
81 workingDir := t.TempDir()
82 manager := newBackgroundShellManager()
82 manager := newBackgroundShellManager()
@@ -119,7 +119,7 @@ func TestBackgroundShellManager_KillNonExistent(t *testing.T) {
119func TestBackgroundShell_IsDone(t *testing.T) {
119func TestBackgroundShell_IsDone(t *testing.T) {
120 t.Parallel()
120 t.Parallel()
122− ctx := context.Background()
122+ ctx := t.Context()
123 workingDir := t.TempDir()
123 workingDir := t.TempDir()
124 manager := newBackgroundShellManager()
124 manager := newBackgroundShellManager()
@@ -142,7 +142,7 @@ func TestBackgroundShell_IsDone(t *testing.T) {
142func TestBackgroundShell_WithBlockFuncs(t *testing.T) {
142func TestBackgroundShell_WithBlockFuncs(t *testing.T) {
143 t.Parallel()
143 t.Parallel()
145− ctx := context.Background()
145+ ctx := t.Context()
146 workingDir := t.TempDir()
146 workingDir := t.TempDir()
147 manager := newBackgroundShellManager()
147 manager := newBackgroundShellManager()
@@ -180,7 +180,7 @@ func TestBackgroundShellManager_List(t *testing.T) {
181 t.Parallel()
181 t.Parallel()
183− ctx := context.Background()
183+ ctx := t.Context()
184 workingDir := t.TempDir()
184 workingDir := t.TempDir()
185 manager := newBackgroundShellManager()
185 manager := newBackgroundShellManager()
@@ -224,7 +224,7 @@ func TestBackgroundShellManager_List(t *testing.T) {
224func TestBackgroundShellManager_KillAll(t *testing.T) {
224func TestBackgroundShellManager_KillAll(t *testing.T) {
225 t.Parallel()
225 t.Parallel()
227− ctx := context.Background()
227+ ctx := t.Context()
228 workingDir := t.TempDir()
228 workingDir := t.TempDir()
229 manager := newBackgroundShellManager()
229 manager := newBackgroundShellManager()
@@ -250,7 +250,7 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
252 // Kill all shells
252 // Kill all shells
253− manager.KillAll(context.Background())
253+ manager.KillAll(t.Context())
255 // Verify all shells are done
255 // Verify all shells are done
256 if !shell1.IsDone() {
256 if !shell1.IsDone() {
@@ -286,19 +286,22 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
286func TestBackgroundShellManager_KillAll_Timeout(t *testing.T) {
286func TestBackgroundShellManager_KillAll_Timeout(t *testing.T) {
287 t.Parallel()
287 t.Parallel()
289+ // XXX: can't use synctest here - causes --race to trip.
289 workingDir := t.TempDir()
291 workingDir := t.TempDir()
290 manager := newBackgroundShellManager()
292 manager := newBackgroundShellManager()
292 // Start a shell that traps signals and ignores cancellation.
294 // Start a shell that traps signals and ignores cancellation.
293− _, err := manager.Start(context.Background(), workingDir, nil, "trap '' TERM INT; sleep 60", "")
295+ _, err := manager.Start(t.Context(), workingDir, nil, "trap '' TERM INT; sleep 60", "")
294 require.NoError(t, err)
296 require.NoError(t, err)
296 // Short timeout to test the timeout path.
298 // Short timeout to test the timeout path.
297− ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
299+ ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)
298− defer cancel()
300+ t.Cleanup(cancel)
300 start := time.Now()
302 start := time.Now()
301 manager.KillAll(ctx)
303 manager.KillAll(ctx)
302 elapsed := time.Since(start)
305 elapsed := time.Since(start)
304 // Must return promptly after timeout, not hang for 60 seconds.
307 // Must return promptly after timeout, not hang for 60 seconds.