gateway: TestClaudeRunsNamesEachProcess waits for the hung run's pid, not only two runs
Red on ubuntu CI under -race at5bfd76cd8(run of the Test workflow): "the run answering, pid 42298, is listed as {PID:0 ...}". The wait took a listing first and read hang.pid after it. A listing made while the second run's launch had started Claude Code but not yet set its tree (983fff23dreads the pid only once the tree is set) has that run at PID 0; by the time the condition read hang.pid the fake had written it, so the wait ended on a list without the hung pid. The condition now also needs a run listed with that pid, which is the state the check after it is about. Run on mote (macOS 27), at this tree: - Injected a 500ms sleep in claudeRuns for a run listed at PID 0 (and 300ms in launch before the tree is set): the old test is red 3 of 3 with CI's exact message, this one is ok -count=3. - Without injection: go test -race -tags nogui -count=5 -run TestClaudeRuns ./internal/gateway: ok. gofmt -l clean. Not changed: the listing itself; a run whose launch hasn't set its tree yet is listed at PID 0, as before.
This commit is contained in:
@@ -122,7 +122,17 @@ func TestClaudeRunsNamesEachProcess(t *testing.T) {
|
||||
l := runsUntil(t, s, "two runs, one answering", func(l ClaudeRuns) bool {
|
||||
b, err := os.ReadFile(filepath.Join(dir, "hang.pid"))
|
||||
hung, _ = strconv.Atoi(strings.TrimSpace(string(b)))
|
||||
return err == nil && hung > 0 && len(l.Runs) == 2
|
||||
if err != nil || hung <= 0 || len(l.Runs) != 2 {
|
||||
return false
|
||||
}
|
||||
// the hung run's pid is listed once launch has set its tree,
|
||||
// a moment after Claude Code wrote hang.pid
|
||||
for _, r := range l.Runs {
|
||||
if r.PID == hung {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
by := map[int]ClaudeRun{}
|
||||
for _, r := range l.Runs {
|
||||
|
||||
Reference in New Issue
Block a user