tests: a whole-output capture must not land in the work tree - #119
Merged
Merged
Conversation
Three live tests photograph the entire output with `grim <file>` — no
geometry — and then copied the result next to the source, under a name
nothing ignores:
damage_integration_test.go live-wayland-damage.png
wayland_integration_test.go live-wayland-capture.png
wlhidpi_integration_test.go live-hidpi-<name>.png
Under headless sway in CI the output holds only the test window. In a
person's own session it holds their screen — their code, their mail, their
tabs — and this repository is public. A .gitignore entry would be a safety
net rather than a barrier: `git add -f`, a fresh clone, or any tool that
does not consult it publishes the file anyway. So they now go through
captureDir: somewhere durable, and inside no git work tree.
internal/cocoa already had that rule, for exactly this reason (#68), and it
was one package's private copy. The rule moves to internal/capture and both
packages read it there, so they cannot drift apart on it.
The `import -window <id>` captures are deliberately left where they are.
They photograph the test's OWN window and nothing else, and this project
keeps dated proof images as reviewable evidence on purpose — the .gitignore
says so. Routing them would have been tidiness overriding a decision
somebody made.
internal/capture is covered but for one branch: filepath.Abs fails only when
the working directory cannot be read, which an ordinary run never meets. It
is kept and its unreachability is stated where it sits, because answering a
half-resolved path is exactly how a capture escapes its directory. The guard
that matters is witnessed — remove the repository check and the test says so
by name.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… pair The Windows lane caught it: clearing HOME and XDG_CONFIG_HOME leaves AppData set, os.UserConfigDir answers happily, and a test asserting there is nowhere to put a capture got a directory back. Which variable is read is the platform's business, so the test clears all of them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
Three live tests photograph the entire output with
grim <file>— nogeometry — and then copied the result next to the source, under a name nothing
ignores:
damage_integration_test.golive-wayland-damage.pngwayland_integration_test.golive-wayland-capture.pngwlhidpi_integration_test.golive-hidpi-<name>.pngUnder headless sway in CI the output holds only the test window. In a person's
own session it holds their screen — their code, their mail, their tabs —
and this repository is public. A
.gitignoreentry would be a safety netrather than a barrier:
git add -f, a fresh clone, or any tool that does notconsult it publishes the file anyway.
They now go through
captureDir: somewhere durable, and inside no git worktree.
One rule, one place
internal/cocoaalready had that rule, for exactly this reason (#68), and itwas one package's private copy. It moves to
internal/capture, and bothpackages read it there.
What is deliberately left alone
The
import -window <id>captures stay where they are. They photograph thetest's own window and nothing else, and this project keeps dated proof
images as reviewable evidence on purpose — the
.gitignoresays so. Routingthem would have been tidiness overriding a decision somebody made.
Tests
The guard that matters is witnessed: remove the repository check and
TestDirRefusesARepositorysays so by name. Both the override path and thedefault path are covered, as are the two failures a run can really meet (no
configuration directory; a destination under a regular file).
internal/captureis covered but for one branch:filepath.Absfails only whenthe working directory cannot be read, which an ordinary run never meets. It is
kept and its unreachability is stated where it sits — answering a half-resolved
path is exactly how a capture escapes its directory.
🤖 Generated with Claude Code