Repository navigation
test: fix output capture that hangs make release-check on macOS - #232
Conversation
Several tests redirected stdout/stderr to a pipe, ran the command, and only then read the pipe. With nothing reading during the write, the command blocks forever once its output exceeds the pipe buffer, and on macOS that buffer can be as small as 512 bytes when the process holds many pipes. TestChatRecent_CommandPathFiltersSortsAndCaps hung this way under make release-check. Those tests now write to a temp file, and the concurrent capture helpers close their read ends. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
SummaryPR #232 switches tests that read command output after execution from pipes to temporary files, avoiding hangs when output exceeds the pipe buffer. It also closes the read ends of the pipes used by two helpers that drain output concurrently. The shallow checkout prevented the three-dot diff, so I compared the PR merge commit with its recorded base, What looks good
Issues found
|
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
SummaryThis PR replaces synchronous stdout and stderr test pipes with temporary files so command output can exceed pipe capacity without hanging the tests. It also closes the read handles in two helpers that drain pipes concurrently. The shallow checkout prevented Git from finding a merge base. I reviewed the tree diff between What looks good
Issues found
No critical issues or warnings found. |
Summary
make release VERSION=1.44.0hung on macOS ingo test ./...and timed out after 10 minutes inTestChatRecent_CommandPathFiltersSortsAndCaps. Test-only change; no product code is touched and no version is bumped (v1.44.0 is not tagged yet, so the tag will simply point atmainafter this merges).Cause
Seventeen tests in
cmd/redirectedos.Stdout/os.Stderrto anos.Pipe(), ran the command, closed the writer and only then read the pipe. Nothing reads while the command writes, so the write blocks forever once the output is larger than the pipe's buffer. The stack from the hang shows exactly that: the test goroutine parked insyscall.writeunderJSONPrinter.Print, writing 910 bytes.That buffer is not a fixed size. macOS gives a pipe as little as 512 bytes when the process already holds many pipe buffers. #230 added a large number of tests that capture output through pipes and run earlier in the package, and the two shared capture helpers never closed their read ends, which is what pushed a later, pre-existing test over the edge. On Linux (CI and the dev container) the pipe buffer is 64 KiB, so nothing blocked and the suite stayed green.
Fix
captureFile(t): a drop-in foros.Pipe()that returns a temp file to write to and a second handle to read it back. A file has no buffer limit. The 17 write-then-read sites incalendar_test.go,chat_test.go,slides_test.go,hooks_test.goandvalidation_test.gouse it.captureStdoutandcaptureStderrStr(which do read concurrently) now close their read ends instead of leaking them.Testing
go vet ./...,go test ./... -count=1andgolangci-lint runpass on Linux.make release-checkcompleting on a Mac.Generated by Claude Code