test: one context assignment per branch so no cancel is lost

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-22 19:26:09 -08:00
1 parent 399bc7699f
commit 4744b8a4c0
1 file changed
+4 -1
@@ -293,9 +293,12 @@ func TestSyncControlsIgnoreAmbientAllocation(t *testing.T) {
// The crash-matrix child is fdatasync-bound and takes 1-35 s on a
// slow disk, so it runs until the parent test's deadline rather
// than a fixed budget.
ctx, cancel := context.WithCancel(context.Background())
var ctx context.Context
var cancel context.CancelFunc
if d, ok := t.Deadline(); ok {
ctx, cancel = context.WithDeadline(context.Background(), d.Add(-10*time.Second))
} else {
ctx, cancel = context.WithCancel(context.Background())
}
defer cancel()
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+tc.test+"$")