@@ -14,7 +14,7 @@ func TestBackgroundShellManager_Start(t *testing.T) {
1414 t.Skip("Skipping this until I figure out why its flaky")
1515 t.Parallel()
1616
17− ctx := context.Background()
17+ ctx := t.Context()
1818 workingDir := t.TempDir()
1919 manager := newBackgroundShellManager()
2020
@@ -51,7 +51,7 @@ func TestBackgroundShellManager_Start(t *testing.T) {
5151func TestBackgroundShellManager_Get(t *testing.T) {
5252 t.Parallel()
5353
54− ctx := context.Background()
54+ ctx := t.Context()
5555 workingDir := t.TempDir()
5656 manager := newBackgroundShellManager()
5757
@@ -77,7 +77,7 @@ func TestBackgroundShellManager_Get(t *testing.T) {
7777func TestBackgroundShellManager_Kill(t *testing.T) {
7878 t.Parallel()
7979
80− ctx := context.Background()
80+ ctx := t.Context()
8181 workingDir := t.TempDir()
8282 manager := newBackgroundShellManager()
8383
@@ -119,7 +119,7 @@ func TestBackgroundShellManager_KillNonExistent(t *testing.T) {
119119func TestBackgroundShell_IsDone(t *testing.T) {
120120 t.Parallel()
121121
122− ctx := context.Background()
122+ ctx := t.Context()
123123 workingDir := t.TempDir()
124124 manager := newBackgroundShellManager()
125125
@@ -142,7 +142,7 @@ func TestBackgroundShell_IsDone(t *testing.T) {
142142func TestBackgroundShell_WithBlockFuncs(t *testing.T) {
143143 t.Parallel()
144144
145− ctx := context.Background()
145+ ctx := t.Context()
146146 workingDir := t.TempDir()
147147 manager := newBackgroundShellManager()
148148
@@ -180,7 +180,7 @@ func TestBackgroundShellManager_List(t *testing.T) {
180180
181181 t.Parallel()
182182
183− ctx := context.Background()
183+ ctx := t.Context()
184184 workingDir := t.TempDir()
185185 manager := newBackgroundShellManager()
186186
@@ -224,7 +224,7 @@ func TestBackgroundShellManager_List(t *testing.T) {
224224func TestBackgroundShellManager_KillAll(t *testing.T) {
225225 t.Parallel()
226226
227− ctx := context.Background()
227+ ctx := t.Context()
228228 workingDir := t.TempDir()
229229 manager := newBackgroundShellManager()
230230
@@ -250,7 +250,7 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
250250 }
251251
252252 // Kill all shells
253− manager.KillAll(context.Background())
253+ manager.KillAll(t.Context())
254254
255255 // Verify all shells are done
256256 if !shell1.IsDone() {
@@ -286,19 +286,22 @@ func TestBackgroundShellManager_KillAll(t *testing.T) {
286286func TestBackgroundShellManager_KillAll_Timeout(t *testing.T) {
287287 t.Parallel()
288288
289+ // XXX: can't use synctest here - causes --race to trip.
290+
289291 workingDir := t.TempDir()
290292 manager := newBackgroundShellManager()
291293
292294 // 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", "")
294296 require.NoError(t, err)
295297
296298 // Short timeout to test the timeout path.
297− ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
298− defer cancel()
299+ ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)
300+ t.Cleanup(cancel)
299301
300302 start := time.Now()
301303 manager.KillAll(ctx)
304+
302305 elapsed := time.Since(start)
303306
304307 // Must return promptly after timeout, not hang for 60 seconds.