Skip to content

test: sandbox the data dir when tests run from a package directory - #1626

Merged
backnotprop merged 1 commit into
mainfrom
test/sandbox-package-dir-runs
Sep 28, 2026
Merged

backnotprop merged 1 commit into
mainfrom
test/sandbox-package-dir-runs

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Follow-up to #1624.

Problem

Bun reads only the bunfig.toml in the directory bun test runs from. The root bunfig.toml preloads tests/setup/feedback-archive-off.ts (temp PLANNOTATOR_DATA_DIR, feedback archive off), but a run from a package directory (cd apps/pi-extension && bun test, cd packages/server && bun test) skipped it and wrote into the contributor's real ~/.plannotator, against the CLAUDE.md Testing Rules.

Fix

  • A bunfig.toml in every apps/* / packages/* directory that contains tests (17), with only a [test] section that mirrors the root preloads via ../../ paths. The setup logic is not duplicated. The happy-dom preload is opt-in (DOM_TESTS=1), so including it changes nothing for a plain run.
  • tests/package-bunfig.test.ts fails when a package gains tests without a bunfig, or when a package bunfig's preloads drift from the root list.
  • packages/server/storage.test.ts: the tilde test created ~/.plannotator/test-plans in the real home on every run, including root runs, because getPlanDir mkdirs its result and os.homedir() ignores a HOME override. It now expands bare ~, which already exists.

CI is unchanged: every workflow runs bun test from the repo root, which still reads only the root bunfig.

Evidence

Fake HOME (temp dir), PLANNOTATOR_DATA_DIR / XDG_DATA_HOME / PLANNOTATOR_FEEDBACK_HISTORY unset, bun test from the package directory.

Run Result Written under $HOME/.plannotator
apps/pi-extension before 320 pass, 0 fail 10 files: feedback/pi-annotate-submission-test-*/index.jsonl + records/*, history/_unknown/annotate-doc-md-*/001.md
apps/pi-extension after 320 pass, 0 fail directory absent
packages/server before 930 pass, 1 skip, 0 fail 60 files: history/test-project/*, history/_unknown/annotate-* (incl. submissions/), history/pkg-sandbox/test-plan-*, feedback/_unknown/records/*, plus empty test-plans/
packages/server after 930 pass, 1 skip, 0 fail directory absent

Root bun test: before 5397 pass / 1244 skip / 0 fail (6641 tests), after 5415 pass / 1244 skip / 0 fail (6659; +18 from the new guard test). apps/guides-show and apps/vscode-extension bun run test pass. bun run typecheck passes.

Bun reads only the bunfig.toml in the directory bun test runs from, so a
run from apps/pi-extension or packages/server skipped the root preloads and
wrote history, feedback and submission records into the real ~/.plannotator.
Mirror the root [test] preloads in every apps/* and packages/* directory that
has tests, guarded by tests/package-bunfig.test.ts. Also stop storage.test.ts
creating ~/.plannotator/test-plans in the real home.
@backnotprop
backnotprop merged commit 8ce0d72 into main Sep 28, 2026
28 checks passed
@backnotprop
backnotprop deleted the test/sandbox-package-dir-runs branch September 28, 2026 15:38
YeKc1M pushed a commit to YeKc1M/plannotator that referenced this pull request Oct 1, 2026
…acknotprop#1626)

Bun reads only the bunfig.toml in the directory bun test runs from, so a
run from apps/pi-extension or packages/server skipped the root preloads and
wrote history, feedback and submission records into the real ~/.plannotator.
Mirror the root [test] preloads in every apps/* and packages/* directory that
has tests, guarded by tests/package-bunfig.test.ts. Also stop storage.test.ts
creating ~/.plannotator/test-plans in the real home.
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