Repository navigation
fix(#842): tsx-spawning integration tests blow vitest's 5s default — phase-registry now uses the prebuilt dist - #843
Merged
admarble merged 3 commits intoJul 29, 2026
Conversation
…fault phase-registry.integration.test.ts spawned `tsx bin/cli.ts`, recompiling the whole TypeScript program per spawn — 4.2s idle on a cold cache, 7.5-17.8s under full-suite load — against vitest's unset-and-therefore-5000ms testTimeout. The behavior under test was always correct; the constant was mis-sized. - Convert phase-registry to the prebuilt `dist/bin/cli.js`, matching its five siblings and the stated purpose of vitest.global-setup.ts. `--phases` is Commander coercion, identical in source and compiled form, so this removes the compile from the hot path rather than widening a tolerance. 4.2s -> 0.25s. - Guard the missing-dist case with a throwing beforeAll, not `describe.skipIf`, so the validation gate cannot silently vanish (AC-6). - Keep sync-source-invocation on tsx — #822's bug lived in runtime `import.meta.url` resolution, so the compile *is* the thing under test and moving to dist would delete the coverage. Instead pair a 60s child timeout with a 90s testTimeout, sized off the 17.8s worst case. - Order every child timeout strictly below its vitest timeout so the child kill wins and reports `SIGTERM` plus captured output, instead of vitest's opaque "Test timed out". Fixes the same unreachable-timeout confusion in precheck.test.ts (30s/60s children under the unit project's 5s default) and tautology-detector-cli.test.ts (30s child equal to the new 30s floor). - Give the integration project a 30s testTimeout floor; the unit project keeps vitest's 5s default, where a slow test is a real signal. Verified: 3 consecutive `vitest run src/lib/workflow src/commands` (87 files, 1713 tests) with zero timeout failures across a 37-72s spread in run duration, plus a full-suite run (219 files, 4575 tests). AC-6 checked by removing dist and confirming a loud failure rather than a green skip. Closes #842
6 tasks
…k at the cause, add a convention guard Second adversarial pass. Three gaps: 1. AC-6 was applied narrowly while AC-3 was applied repo-wide — inconsistent. cli.integration.test.ts carried a describe.skipIf(!distExists) block whose only test asserted expect(distExists).toBe(true): skipped in exactly the case it would have failed, so it could never fail under any condition. run-tui.integration.test.ts's two flag-wiring assertions vanished silently on an unbuilt tree via it.skipIf. Both now fail loudly via the throwing beforeAll guard, naming the missing path and the remedy. 2. The precheck CLI fix treated the symptom, not the cause. A 90s ceiling left the two `npx tsx` spawns in the unit project, where fileParallelism is ON and they race every other unit file for CPU — the exact contention fileParallelism: false exists to prevent. The CLI block moves to precheck-cli.integration.test.ts (integration project by name: serialized, 30s floor, 90s ceiling kept strictly above the 60s child timeout). The 28 in-process precheck tests stay in the parallel unit project. 3. Nothing stopped the silent-skip pattern coming back — three files had independently reached for it. scripts/qa/dist-skip-guard.test.ts now walks every test file and fails naming the offender on any dist-conditioned skipIf. Comments are stripped before matching (the fixed files quote the forbidden pattern in their own explanatory comments). Mutation-verified: planting a real describe.skipIf(!distExists) fails the guard with the planted file's path; removing it goes green. Verified: both converted files fail loudly against a genuinely absent dist (no globalSetup, dist removed); full suite 221 files / 4576 passed. Deleted test note: the "dist/ directory exists" test is removed because it was tautological (see 1) — its job is now done by a guard that actually runs when dist is missing.
Contributor
Author
|
Round 2 pushed in |
admarble
deleted the
feature/842-fix-test-tsx-spawning-integration-tests-blow-v
branch
July 29, 2026 04:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
phase-registry.integration.test.tsspawnedtsx bin/cli.ts, recompiling the whole TypeScript program on every spawn, against a 5000 ms budget thatvitest.config.tsnever set explicitly. The behavior under test was always correct — the constant was mis-sized.phase-registryto the prebuiltdist/bin/cli.js(AC-1), matching its five siblings and the stated purpose ofvitest.global-setup.ts.--phasesis Commander argument coercion, byte-identical in source and compiled form, so this removes the compile from the hot path rather than widening a tolerance. Measured 4.2 s → 0.25 s per test.distwith a throwingbeforeAll, notdescribe.skipIf(AC-6) — a skip would let the validation gate silently vanish for anyone running vitest without a build.sync-source-invocationontsx(AC-2). fix(templates): getTemplatesDir resolves one level too high under tsx — source-run sync/init prints "✔ Synced" while installing nothing #822's bug lived in runtimeimport.meta.urlresolution, so the compile is the thing under test; moving it todistwould delete the coverage. It gets a 60 s child timeout paired with a 90 stestTimeoutinstead, sized from measurement.spawnSynctimeout:is a child-process kill, not a test timeout — the old 30 s and 120 s values sat above the 5 s default and could never fire.testTimeoutfloor to theintegrationproject only (AC-5);unitkeeps vitest's 5 s.Beyond the named files
AC-3 is phrased repo-wide, so I audited every
execSync/spawnSyncchild timeout rather than only the two files the issue names. Two further live violations of the same class turned up:scripts/qa/precheck.test.ts.integration.infix, so it sits in theunitprojectscripts/qa/tautology-detector-cli.test.tsprecheck.test.tsshells out tonpx tsxtwice under a 5 s budget — a live flake of exactly this class that simply hadn't been diagnosed yet.src/lib/workflow/state-update-cli.test.tsalready pairs 30 s/60 s correctly and is left untouched — it's the precedent the rest now follow.AC coverage
tsxinvocation remains (only header prose explaining the change); assertions unchangedtsxBinstill used;testTimeout: 90_000with a comment justifying both thetsxrequirement and the numbervitest run src/lib/workflow src/commands— 87 files, 1713 tests, zero timeout failuresintegrationblock with a justifying comment;unitblock untoucheddistand confirming a loud failure, not a green skipTest plan
npm run buildandnpm run lintcleannpx vitest run src/lib/workflow src/commands— all green across a 37→72 s spread in run duration, which is the load variance that used to break thisrm -rf dist+ a config withoutglobalSetup→ suite fails naming the missing path and telling the reader to runnpm run buildtsxanddist— identical validator output, confirming the conversion preserves what the test assertsNotes for the reviewer
gpg-agentcould not launchpinentryin the non-interactive session that produced them, and I did not want to silently disable your signing config. Re-sign before merge if you want the branch to match repo convention.src/lib/workflow/qa-stagnation.test.tsfails locally for anyone with globalcommit.gpgsign = true— its temp repos don't disable signing, sogit commitdies withgpg: signing failed: No pinentry. This is the known environmental condition, not a defect in this PR; reproduced identically on unmodifiedmain. The AC-4 and full-suite runs above were done with that confound neutralized viaGIT_CONFIG_*env vars only — your global git config was not touched.Closes #842