Skip to content

Approve stdout and stderr separately in every approval test - #58

Closed
MPV wants to merge 1 commit into
masterfrom
claude/approve-stdout-stderr
Closed

Approve stdout and stderr separately in every approval test#58
MPV wants to merge 1 commit into
masterfrom
claude/approve-stdout-stderr

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Give the approval suite a shared verify(t, file) helper that approves what the tool prints to stdout (the images) and to stderr (the error message, if any) as two separate golden files, and route every test through it.

Requires bumping go-approval-tests v1.2.0 → v1.5.0 for Options().WithAdditionalInformation(...). .received.txt files are gitignored.

Why

The suite only captured stdout, so a change to what a manifest sends to stderr — an error appearing or disappearing — was invisible. Later PRs change exactly that (treating an unsupported kind as skippable; the CLI's exit/stderr behavior), and those changes should land as reviewable golden-file diffs rather than silent shifts.

What's in the diff

Nine verify() call sites, each gaining a .stdout + .stderr golden (the old single-stream .approved.txt is renamed to .stdout.approved.txt, and a .stderr.approved.txt is added):

  • 8 success cases — the 7 TestKind kinds and TestMultiple — carry an empty .stderr golden. That empty golden is the point: a regression that leaked to stderr on a passing manifest would now fail the suite.
  • 1 error caseTestError.Service — carries a non-empty .stderr golden holding the current text, error processing document: unsupported kind Service. This is the baseline that Skip non-workload documents instead of aborting the stream #54 later flips to empty when a Service becomes skippable.

Behavior change

None — test-infrastructure only (test code + go.mod/go.sum + .gitignore). Supersedes the draft #46 (which converted only the error test and wasn't gofmt-clean).

Stack

Base of both stacks: parsing (#49#54#56) and CLI (#50#55#57).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC

The approval tests only captured stdout (the image list), so a change to
the error text a failing manifest produces was invisible to the suite.
Behavior changes in later PRs — e.g. treating an unsupported kind as
skippable rather than an error — should show up as a reviewable
golden-file diff, which requires capturing stderr too.

Verify stdout and stderr as separate approved files using
go-approval-tests' WithAdditionalInformation (which needs v1.5.0). The
existing Service golden becomes the .stdout file (still empty) and a new
.stderr golden captures the current error message. Received files are
gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
@MPV
MPV force-pushed the claude/approve-stdout-stderr branch from 929d8a3 to a0611cd Compare July 23, 2026 08:17
@MPV MPV changed the title Approve stdout and stderr separately in the error test Approve stdout and stderr separately in every approval test Jul 23, 2026
@MPV MPV closed this Jul 23, 2026
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