TestDoLastSourceUsesRemainingBudget slept 1100ms (official) and 700ms
(mirror) under a 2s parent, leaving ~300ms for scheduling. It now uses a
controlled RoundTripper: the official request waits on its candidate
context and must end with context.Canceled (its half of the budget), and
the mirror request must carry the parent's deadline and end with
DeadlineExceeded no earlier than it. A second test adds #2608's 350ms
pause before the mirror request. Patch by ump45nose; the review dropped
an unused parentDeadline field.
What ran (worktree at origin/main 81313b912, sandbox HOME, go1.26.8
darwin/arm64, load ~270-300):
- Flake reproduced: main's test with a 350ms pause before the mirror
request: FAIL in 2.06s (official canceled, mirror deadline exceeded).
The new tests pass with and without that pause.
- Broken by hand, both new tests red: candidateContext(..., true) for the
last candidate ("mirror request ended with context canceled 495ms
before the parent's deadline"), and a WithTimeout(remaining/2) on the
last candidate ("mirror deadline = ..., want the parent's ...").
- gofmt -l . clean; go vet -tags nogui ./... for darwin, linux, windows.
- set -o pipefail; go test -count=1 -timeout 45m ./...: 65 packages ok,
internal/source ok, internal/gateway ok (1430s). internal/gui red on
TestMainWindowCorners (both SDKs "measuring the windows: signal:
killed" at its 40s deadline, #1936) and, on a rerun of internal/gui
alone, TestSetAnswersWhileDevinAndProvidersHang (#1375). Both are
filed load reds in a package this commit doesn't touch.
Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>