Skip to content

fix(testing): load the isolated postgres fixture from an owned temporary file - #1212

Merged
0xPlayerOne merged 2 commits into
mainfrom
fix/bun-coverage-fixture-import
Oct 21, 2026
Merged

0xPlayerOne merged 2 commits into
mainfrom
fix/bun-coverage-fixture-import

Conversation

@0xPlayerOne

@0xPlayerOne 0xPlayerOne commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Coverage fixture cleanup on every post-allocation failure

Current head: 75c2f498d953cc5e9457c7534174c641e7159f7a (tree 5bb0ea3a787cecdb18747a593c76fb7b104a0bae), based on the existing PR head 085930170ed6c9ea9d88162d3b6ad5f663efb630.

This repair keeps cleanup active for every failure after a fixture directory is allocated, including directory setup, fixture writes, and module loading. Cleanup errors are retained alongside the original failure. Tests use owned temporary fixture directories only; no shared-resource cleanup is performed.

Checks

  • Focused ordinary and coverage runs: 14 passed, 0 failed, 39 assertions.
  • Five deterministic post-allocation failure paths and mutation checks passed (5/5).
  • Coverage run completed without a Bun panic or leaked temporary directory; thresholds were not changed.
  • The seeded broader unit lane completed with 4,325 passed, 11 skipped, 6 failed, and 1 error under a 965-second contended run. These remaining failures are unresolved and are not represented as a passing aggregate result.

Draft update for review. Auto-merge remains off; no readiness, merge, deployment, or issue-closure claim is made.

…ary file

The isolated postgres fixture was bundled and then imported from a
data:text/javascript;base64 URL. The coverage reporter of the pinned Bun
1.4.3 cannot report a module loaded that way: it aborts the whole coverage
run with "panic: range end index 1884 out of range for slice of length 1024"
before it prints a summary, so every coverage run that included
packages/testing/src/postgres.test.mjs died at the reporting step.

The bundle is now written to a temporary file the test owns and imported from
there. The bytes are the ones the build produced, the fixture behaves the
same, and the directory is removed when the run ends and when the fixture
cannot be loaded at all. The file lives in a dist/ directory because it is
generated output, which the repository's coverage configuration already
ignores, so the coverage report keeps exactly the rows it had.

Three regressions cover the new path: the fixture loads from the temporary
file with the bundle's own bytes, the owned directory is removed, and a
fixture that cannot be loaded leaves nothing behind either.
@0xPlayerOne 0xPlayerOne changed the title fix: bun-coverage-fixture-import fix(testing): load the isolated postgres fixture from an owned temporary file Oct 21, 2026
…er its allocation

The fixture directory is allocated, then filled, then written and then
imported, and each of those steps can fail. Only the import was guarded: a
directory that was allocated and then not filled, or a file that could not be
written, stayed behind in the temporary directory, and the removal was
registered only after a successful load.

The allocation and the directory creation are now one guarded step, the write
is guarded as well as the import, and the removal is registered before the
fixture is loaded. The failure that caused the cleanup is kept as it is; a
cleanup that fails too is reported beside it rather than in place of it, so
the original error is never lost.

Four regressions cover the paths: a directory that cannot be created, a file
that cannot be written and a fixture that cannot be imported each leave no
directory behind, a cleanup that fails is reported next to the failure that
caused it, and a directory the test does not own is left untouched.

The bundle bytes and the coverage thresholds are unchanged.
@0xPlayerOne
0xPlayerOne marked this pull request as ready for review October 21, 2026 12:23
@0xPlayerOne
0xPlayerOne merged commit df37ca8 into main Oct 21, 2026
63 checks passed
@0xPlayerOne
0xPlayerOne deleted the fix/bun-coverage-fixture-import branch October 21, 2026 12:31
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