Skip to content

test: fix output capture that hangs make release-check on macOS - #232

Merged
omriariav merged 2 commits into
mainfrom
claude/charming-brahmagupta-jhwxir
Nov 26, 2026
Merged

omriariav merged 2 commits into
mainfrom
claude/charming-brahmagupta-jhwxir

Conversation

@omriariav

Copy link
Copy Markdown
Owner

Summary

make release VERSION=1.44.0 hung on macOS in go test ./... and timed out after 10 minutes in TestChatRecent_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 at main after this merges).

Cause

Seventeen tests in cmd/ redirected os.Stdout / os.Stderr to an os.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 in syscall.write under JSONPrinter.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

  • New test helper captureFile(t): a drop-in for os.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 in calendar_test.go, chat_test.go, slides_test.go, hooks_test.go and validation_test.go use it.
  • captureStdout and captureStderrStr (which do read concurrently) now close their read ends instead of leaking them.

Testing

  • go vet ./..., go test ./... -count=1 and golangci-lint run pass on Linux.
  • Not verified on macOS from here. The diagnosis rests on the stack dump from the hung run; the confirmation is make release-check completing on a Mac.

Generated by Claude Code

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
@github-actions

Copy link
Copy Markdown

Summary

PR #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, origin/main. make test could not initialize the Go build cache on the read-only filesystem.

What looks good

  • The temporary-file helper preserves the existing command invocations and output assertions. Its separate read handle starts at the beginning of the captured output.
  • The concurrent capture helpers close their read handles after the reader finishes. No CLI commands or flags changed.

Issues found

  • Warning — Fourteen call sites discard the error from captureFile. If creating or opening the capture file fails, the helper returns nil handles, and the test can replace os.Stdout or os.Stderr with nil and obscure the setup error. Check the error before redirecting either stream, or have the helper call t.Fatalf on setup failure. First affected call site
  • Suggestion — Two setup errors still refer to creating a pipe after the switch to a temporary file. Update the messages to say “capture file” so a failure points to the right operation. Chat test · Validation helper

@github-actions

Copy link
Copy Markdown

Summary

This 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 origin/main and the PR merge commit after verifying that origin/main was its first parent.

What looks good

  • The capture helper uses separate read and write handles, so callers can read from the beginning after the command finishes. It registers cleanup for both handles and reports setup failures at the calling test.
  • The changes are test-only. The command registration, HTTP mocks, and CLI documentation requirements for new commands do not apply.

Issues found

  • Suggestion — captureFile always returns a nil error because setup failures call t.Fatalf. Return just the two file handles and remove the unreachable error checks at the call sites. raw_runners_test.go

No critical issues or warnings found. git diff --check passed. make test could not start because the read-only filesystem prevented Go from creating its build cache.

@omriariav
omriariav merged commit 7e898fa into main Nov 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants