cast/test
dan-claude-bot 7f0e886851 fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites
The suite allocated temp dirs at 68 sites across 21 files and removed none,
accumulating ~6700 directories and 189MB per machine-day, some holding age
keys. All 68 now go through a single `tmp()` helper allocating inside a
per-run root that vitest's globalSetup teardown removes wholesale, and a
class-guard test fails if `mkdtempSync` appears under test/ outside the
helpers.

The per-worker `process.once("exit")` reaper that suggests itself here does
not work under vitest and fails silently: the pool recycles workers by
killing them, so exit handlers registered in a test file never run. Measured
— a probe test writing from an exit hook produced no file, and a full run
with per-worker hooks still left 750 directories. globalSetup's teardown runs
in the main process, after every worker, and vitest awaits it.

Separately, and contrary to #117's framing that "cast itself does not leak":
resolveCheckout() mkdtemps an `infra-checkout-` dir, clones the infra repo
into it, and never removes it, so every `cast apply`/`diff`/`capture` without
--path leaked a full clone. The box that reported #117 was holding 602 such
directories, 73MB of real .git trees, from the same day. The leak fires on
the failure path too, since the dir is created before the clone runs.
Ephemeral checkouts are now reaped on process exit — the lifetime that fits,
since callers read the tree after resolveCheckout returns; a --path checkout
is the operator's own tree and is never registered.

Empirical: /tmp/cast-* + /tmp/infra-* count is 0 before and 0 after a full
`npm test`, against 750 with the exit-hook design. 626 tests green.

Refs #117
2026-07-21 12:58:14 +00:00
..
fixtures feat(service): set and diff per-container service hostnames via urls (#72) 2026-07-16 15:14:29 +00:00
helpers fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
apply.test.ts fix(diff): compare non-secret env vars against fresh value, not stale real_value (#78) 2026-07-16 14:53:00 +00:00
backup-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
bindings.test.ts fix: smoke resolves its target inside the project it was declared under (#29) 2026-07-13 20:08:35 +00:00
capture-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
capture.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
config.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
coolify.test.ts fix(draft): read backup schedules and emit backup blocks (#75) 2026-07-16 18:25:34 +00:00
destroy.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
diff.test.ts fix(diff): compare non-secret env vars against fresh value, not stale real_value (#78) 2026-07-16 14:53:00 +00:00
domain-preflight.test.ts feat(service): set and diff per-container service hostnames via urls (#72) 2026-07-16 15:14:29 +00:00
draft-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
draft.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
envtemplate.test.ts feat(resolve): derive base-URL env vars from manifest domains via ${domain:...} (#66) 2026-07-15 12:02:33 +00:00
fleet-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
fleet.test.ts feat: --all — every project in an environment, and a report that says so (#26) 2026-07-13 20:23:23 +00:00
github-app-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
greenfield-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
install-sh.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
inventory.test.ts feat: read-side coordinates (#17, #18) + cast inventory (#19) 2026-07-13 18:20:53 +00:00
labels-reconcile.sh fix(labels): a missing state label skips the edit, not the whole PR 2026-07-20 18:09:16 +00:00
layout-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
live-lookup.test.ts feat(draft): capture service hostnames via per-service GET (#83) 2026-07-16 18:30:49 +00:00
manifest.test.ts fix(apply): express static-site build settings so a monorepo app is served, not run (#63) 2026-07-14 23:46:14 +00:00
placement-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
read-side-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
release.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
reserved.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
resolve.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
secrets.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
smoke-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
smoke.test.ts feat: cast — the Coolify executor, extracted from the infra state repo 2026-07-11 12:25:44 +00:00
sweep-cli.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
team.test.ts feat: assert the token's team before touching Coolify (fail-closed) 2026-07-12 20:55:04 +00:00
tmp-guard.test.ts fix: reap temp dirs — a runtime clone leak in resolveCheckout, and 68 uncleaned test sites 2026-07-21 12:58:14 +00:00
version-cli.test.ts refactor: rescope to versioned installations — the release flow moves out 2026-07-18 21:17:59 +00:00
wire.test.ts fix: resolve the GitHub App only when the manifest declares applications (#103) 2026-07-19 12:26:35 +00:00