From b515503bbf1796779da85631bf4a7c21f11636fd Mon Sep 17 00:00:00 2001 From: Diogo Silva Sena <227921880+DougBTW@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:32:32 -0400 Subject: [PATCH 1/2] test: every test gets its own HOME, so none write the real ~/.cache tests/helpers.bash now points HOME at the test's BATS_TEST_TMPDIR (with a .gitconfig carrying the test identity) and unsets the XDG dirs. Tests that kept the real HOME wrote the CLI's caches into the operator's ~/.cache/found-issues (mode_foo_bar rewritten during a suite run, measured 2026-10-29) and shared them with tests running beside them. tests/test-isolation.bats: HOME is per test, a real mode-cache write lands in it and not in the account's home, commits work without fi_init_git. Red before the change (the leak file appeared in the real cache), green after. Full parallel suite: 2058 tests, no file in the real ~/.cache/found-issues written during the run. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MVx3HWniZnrXYfPiCo5Lrs --- README.md | 2 +- tests/helpers.bash | 12 ++++++++++ tests/test-isolation.bats | 47 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/test-isolation.bats diff --git a/README.md b/README.md index d9641d2..e7713aa 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![Claude Code plugin](https://img.shields.io/badge/Claude%20Code-plugin-orange.svg)](https://docs.claude.com/en/docs/claude-code/plugins) [![Codex plugin](https://img.shields.io/badge/Codex-plugin-black.svg)](AGENTS.md#installing-for-codex) -**7 lifecycle hooks · 14 slash commands · 2055 tests on Linux/macOS · zero manual bookkeeping** +**7 lifecycle hooks · 14 slash commands · 2058 tests on Linux/macOS · zero manual bookkeeping** ![demo](hero.gif) diff --git a/tests/helpers.bash b/tests/helpers.bash index adce7e2..dc3a947 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -27,6 +27,18 @@ export FOUND_ISSUES_SEGMENT_AUTOSYNC=off # --jobs) shared and mixed one another's logs. export FOUND_ISSUES_CACHE_DIR="${BATS_TEST_TMPDIR:-${BATS_RUN_TMPDIR:-${TMPDIR:-/tmp}}}/fi-test-cache" +# A HOME of its own for every test (ledger tests/helpers.bash:25): tests that +# kept the real one wrote the CLI's caches into the operator's ~/.cache, and +# shared them with every test running beside them. The XDG variables would +# point back outside it, so they go too; tests that need one set their own. +# Git identity for commits made without fi_init_git comes from this HOME's +# own .gitconfig (CI's global identity lived in the old HOME). +export HOME="${BATS_TEST_TMPDIR:-${BATS_RUN_TMPDIR:-${TMPDIR:-/tmp}}}/home" +mkdir -p "$HOME" +[[ -f "$HOME/.gitconfig" ]] \ + || printf '[user]\n\tname = Test\n\temail = test@example.com\n' > "$HOME/.gitconfig" +unset XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_STATE_HOME + # A suite started inside an auto-fix run inherits FOUND_ISSUES_AUTOFIX_CHILD=1, # which makes session-start take its headless path and fails every test of # the interactive one, and FI_AF_PID, which a test's claim records and its diff --git a/tests/test-isolation.bats b/tests/test-isolation.bats new file mode 100644 index 0000000..6952dc9 --- /dev/null +++ b/tests/test-isolation.bats @@ -0,0 +1,47 @@ +#!/usr/bin/env bats +# Tests never touch the real home directory (ledger tests/helpers.bash:25). +# A suite run on 2026-10-29 rewrote the operator's ~/.cache/found-issues/ +# mode_foo_bar: tests that kept the real HOME wrote the CLI's caches there, +# and under bats --jobs those files were shared between tests running side +# by side. + +load 'helpers' + +# The account's home from the password database, whatever $HOME says. +real_home() { eval printf '%s' "~$(id -un)"; } + +setup() { + fi_setup_tmp + fi_init_git + LEAK_SLUG="fileakcheck/t$$" + LEAK_FILE="$(real_home)/.cache/found-issues/mode_fileakcheck_t$$" +} + +teardown() { + # Only this test's own uniquely named file, if a leak put it there. + rm -f "$LEAK_FILE" + fi_teardown_tmp +} + +@test "isolation: HOME is a per-test directory, not the real home" { + [ "$HOME" != "$(real_home)" ] + [[ "$HOME" == "$BATS_TEST_TMPDIR"/* ]] +} + +@test "isolation: a CLI cache write lands in the test HOME, not the real one" { + fi_source_lib detect-mode + fi_use_gh_shim + git remote add origin "https://github.com/$LEAK_SLUG.git" + export GH_MOCK_PR_LIST='[]' + unset FOUND_ISSUES_MODE + fi_detect_mode >/dev/null + [ -f "$HOME/.cache/found-issues/mode_fileakcheck_t$$" ] + [ ! -e "$LEAK_FILE" ] +} + +@test "isolation: git commits still work in the per-test HOME" { + git config --unset user.name + git config --unset user.email + git commit --allow-empty -q -m "no local identity" + [ "$(git log -1 --format=%ae)" = "test@example.com" ] +} From eb53b9f2fd3323b8f78127076605f78165911b3f Mon Sep 17 00:00:00 2001 From: Diogo Silva Sena <227921880+DougBTW@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:32:47 -0400 Subject: [PATCH 2/2] docs(found-issues): annotate tests/helpers.bash:25 with PR #298 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MVx3HWniZnrXYfPiCo5Lrs --- docs/found-issues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/found-issues.md b/docs/found-issues.md index 488a34f..1b5f725 100644 --- a/docs/found-issues.md +++ b/docs/found-issues.md @@ -58,4 +58,4 @@ Maintained automatically by Claude. See