Skip to content

feat(testing): the shared test setup waits for a machine-wide test slot - #677

Merged
leemour merged 2 commits into
mainfrom
feat/test-machine-slots
Nov 21, 2026
Merged

leemour merged 2 commits into
mainfrom
feat/test-machine-slots

Conversation

@leemour

@leemour leemour commented Nov 21, 2026

Copy link
Copy Markdown
Member

Why

Several agents ran test suites on one machine at once. Each run had up to 4 vitest workers, and together they took every core and all the memory until the computer froze.

What

  • src/testing/machine-slot.ts: a test file takes one of 8 slot files in ~/.cache/wirecat-test-slots, and only when at least 4 GB of memory is available. It gives the slot back in afterAll. A dead process's slot is taken back. After 10 minutes the file runs without a slot. A wait over 30 s prints who holds the slots.
  • src/testing/setup.ts takes the slot before the sandbox. CI skips the guard. WIRECAT_TEST_SLOTS=0 turns it off.
  • Changelog entry under Added (a minor release), and a paragraph in docs/dev/TESTING.md.

Testing

  • src/testing/machine-slot.test.ts: 5 tests.
  • Three suites of 25 files each (src/codegen src/dev), run at once with WIRECAT_TEST_SLOTS=3: never more than 3 slots held, none left behind, 390 of 390 passed in each run.
  • The full suite gives 6 failures in scripts/release-checks.test.ts, the same with WIRECAT_TEST_SLOTS=0. They come from this machine: the test calls python3 through the asdf shim, and with the sandboxed HOME the shim finds no Python version and exits with 126. Not from this change.

🤖 Generated with Claude Code

@leemour
leemour force-pushed the feat/test-machine-slots branch from c34eb88 to e36df4a Compare November 21, 2026 02:20
Several agents ran test suites on one machine at once. Each run had its own
vitest workers (maxWorkers 4), and together they took every core and all the
memory until the computer froze.

The setup from @wirecat/cli-base/testing/setup now takes one of 8 slot files
in ~/.cache/wirecat-test-slots before a test file starts, and only when at
least 4 GB of memory is available (os.freemem, MemAvailable on Linux). The
slot is given back in afterAll. A slot whose process is dead is taken back
by the next caller. After 10 minutes a file runs without a slot. A wait over
30 seconds prints the holders' PIDs and the off switch. CI skips the guard.
WIRECAT_TEST_SLOT_HELD stops a child vitest from waiting on its parent.

Settings: WIRECAT_TEST_SLOTS (0 turns it off), WIRECAT_TEST_MIN_FREE_GB,
WIRECAT_TEST_MAX_WAIT_S, WIRECAT_TEST_SLOT_DIR.

Checked: three suites of 25 files run at once with 3 slots never held more
than 3 and left none behind, all 390 tests passed in each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour force-pushed the feat/test-machine-slots branch from e36df4a to 33522e9 Compare November 21, 2026 02:22
…ives back only its own slot

A slot file was created empty and written a moment later. Another run that
read it in between saw no PID, took it for a dead run's slot and removed it,
so two runs held the same slot and the first release removed the second's.
Now the owner is written to a temporary file that is hard-linked into place,
and release removes the slot only when it still names this run.

Checked: four suites at once with 2 slots never held more than 2 and left
none behind; a file whose only slot was held waited 90 s, ran without a slot
and passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit 650bdaf into main Nov 21, 2026
10 checks passed
@leemour
leemour deleted the feat/test-machine-slots branch November 21, 2026 03:00
@leemour leemour mentioned this pull request Nov 21, 2026
leemour added a commit that referenced this pull request Nov 21, 2026
Dates #677 (the shared test setup waits for a machine-wide test slot)
and #683 (a sign-in method in `--wcat-describe` can name `--site` and
`--login`) as 0.126.0. Both are Added, so a minor release. The #683
fragment is collected into the section, as 0.125.3 did by hand.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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