Skip to content

tests: a whole-output capture must not land in the work tree - #119

Merged
tannevaled merged 2 commits into
mainfrom
grim-captures-outside-the-repo
Sep 11, 2026
Merged

tannevaled merged 2 commits into
mainfrom
grim-captures-outside-the-repo

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The defect

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:

file capture
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.

They now go through captureDir: somewhere durable, and inside no git work
tree.

One rule, one place

internal/cocoa already had that rule, for exactly this reason (#68), and it
was one package's private copy. It moves to internal/capture, and both
packages read it there.

What is deliberately left alone

The import -window <id> captures stay 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.

Tests

The guard that matters is witnessed: remove the repository check and
TestDirRefusesARepository says so by name. Both the override path and the
default path are covered, as are the two failures a run can really meet (no
configuration directory; a destination under a regular file).

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 — answering a half-resolved
path is exactly how a capture escapes its directory.

🤖 Generated with Claude Code

tannevaled and others added 2 commits September 11, 2026 18:59
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&apos;s business, so the test clears all of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 5067881 into main Sep 11, 2026
28 checks passed
@tannevaled
tannevaled deleted the grim-captures-outside-the-repo branch September 11, 2026 17:04
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.

1 participant