package runner import ( "path/filepath" "testing" "time" ) // The stdout cap must END an endless writer, not merely stop reading it. The mechanism is exec's // own: when limitedBuffer refuses a Write, the copy goroutine closes the pipe's read end («in case // io.Copy stopped due to write error», os/exec writerDescriptor) and the child dies on EPIPE at // its next print — no explicit Kill here, unlike drain(), whose StdoutPipe reader gets no such // help. A workflow review claimed the child blocks on a full pipe until the caller's deadline; // this pin is the refutation, and it is what fails if the cap ever stops refusing the Write. func TestAnEndlessBankApplyIsRefusedRatherThanRead(t *testing.T) { bin := fakeEngine(t, `exec yes '{"report_version":"tm-bank-decisions-report-v2"}'`) start := time.Now() _, err := New(nil).BankApply(t.Context(), bin, t.TempDir(), filepath.Join(t.TempDir(), "d.json"), false) if err == nil { t.Fatal("an endless report was read to the end") } if took := time.Since(start); took > 30*time.Second { t.Fatalf("the overflow did not end the child: the call took %v", took) } }