Skip to content

cocoa live tests: write captures to captureDir, never the working directory - #136

Merged
tannevaled merged 1 commit into
mainfrom
fix/cocoa-capture-outside-repo
Oct 5, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix/cocoa-capture-outside-repo

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The defect

TestLiveCocoaWindow wrote a window-server screenshot (screencapture -l) and its own render into the package directory. That directory is this public repository, so the files sat one git add -f away from publication; the .gitignore entry is a safety net, not a barrier. writeArtifact, used by the legibility, drag-and-drop and vibrancy proofs, did the same. Found during #135: a run left internal/cocoa/cocoa-screencapture-2026-08-10.png in a worktree. It has been moved out.

The fix

  • All three writers go through captureDir, which uses go-appdirs/outdir and refuses any directory inside a git work tree.
  • The directory is resolved on the test goroutine, before callOnMain. captureDir fails the test when the directory is refused, and a t.Fatal inside the main-thread closure ends the closure, not the test: the test then waited forever. That hang is how the refused case first showed up.
  • CI: the darwin live step sets WINDOW_CAPTURE_DIR under runner.temp, outside the checkout, and the artifact upload reads from there.

Checked live on macOS, both directions

  • Default directory: the test passes, both PNGs land under ~/Library/Application Support/go-widgets-window/captures/, and git status --ignored shows no PNG in the tree.
  • WINDOW_CAPTURE_DIR inside the work tree: FAIL in 0.2 s, the message names the tree, and nothing is created.

Tests only; no release needed.

🤖 Generated with Claude Code

…ectory

TestLiveCocoaWindow wrote a window-server screenshot (screencapture -l) and
its own render into the package directory. That directory is this public
repository, so the files sat one `git add -f` away from publication, and the
.gitignore entry is a safety net, not a barrier. writeArtifact, used by the
legibility, drag-and-drop and vibrancy proofs, did the same. All three
writers now go through captureDir (go-appdirs/outdir), which refuses any
directory inside a git work tree.

The capture directory is resolved on the test goroutine, before callOnMain.
captureDir fails the test when the directory is refused, and a t.Fatal from
inside the main-thread closure ends that closure, not the test: the test
then waited forever. That hang is how a refused directory showed up at
first.

CI: the darwin live step sets WINDOW_CAPTURE_DIR under runner.temp, outside
the checkout, and the artifact upload reads from there.

Checked live on macOS, in both directions. With the default directory the
test passes, writes both PNGs under ~/Library/Application Support, and
leaves no PNG in the work tree, ignored ones included. With
WINDOW_CAPTURE_DIR inside the work tree it fails in 0.2 s, naming the tree,
and creates nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 2f54949 into main Oct 5, 2026
28 checks passed
@tannevaled
tannevaled deleted the fix/cocoa-capture-outside-repo branch October 5, 2026 14:26
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