Skip to content

test: run CLI entry tests in-process so V8 coverage attributes them - #65

Merged
altaywtf merged 1 commit into
mainfrom
chore/63-subprocess-coverage
Aug 20, 2026
Merged

test: run CLI entry tests in-process so V8 coverage attributes them#65
altaywtf merged 1 commit into
mainfrom
chore/63-subprocess-coverage

Conversation

@altaywtf

Copy link
Copy Markdown
Member

Summary

Fixes #63. Mirrors the design from the sibling issue, landed in putdotio/taizn#62 (one design, two applications): subprocess-spawned CLI tests execute real code V8 coverage never attributes, understating the floor set in #61.

Design decision (shared): no released vitest can attribute subprocess coverage — vitest 4.1.10/4.1.11 has zero NODE_V8_COVERAGE handling; coverage.autoAttachSubprocess exists only in unreleased Vitest 5.0. Manual NODE_V8_COVERAGE plumbing + sourcemapped bundle remapping through a custom coverage provider is disproportionate machinery. So spawn-based tests were restructured to run the same entry in-process where the subprocess boundary isn't the thing under test.

Changed

  • --completions and the package usage-error tests now run mainEffect(argv) in-process with console spies (rokit's entry was already importable and argv-parameterized, so no source changes were needed).
  • The boot test still spawns dist/rokit.mjs — the process boundary is the thing under test there. That blind spot (the src/rokit.ts shim, already excluded from coverage) is now documented in vite.config.ts and AGENTS.md with the vitest 5 pointer.
  • Coverage floors raised to the new measured baseline minus ~3-point headroom.

Risks

Low: test-only change plus threshold/doc updates. The in-process harness restores process.exitCode and console spies in a finally.

Verification

vp run verify green (check, skillcheck lint, typecheck, pack, smoke, coverage thresholds, npm pack).

Coverage delta (vp test run --coverage, same denominators):

Metric Before After Old floor New floor
Statements 65.91% 68.96% 63 66
Branches 53.42% 55.88% 51 53
Functions 57.86% 60.73% 55 58
Lines 65.83% 68.73% 63 66

Follow-Ups

When vite-plus ships vitest 5, enable coverage.autoAttachSubprocess and re-measure to close the boot-test blind spot (same follow-up as taizn).

Mirrors the design landed in putdotio/taizn#62. Vitest 4 cannot attribute
V8 coverage from spawned subprocesses (coverage.autoAttachSubprocess lands
in vitest 5), and NODE_V8_COVERAGE plumbing plus bundle remapping is
disproportionate machinery. rokit's mainEffect(argv) was already
importable, so the completions and usage-error spawn tests now run it
in-process with console spies; only the boot test still spawns the
packaged binary, and that blind spot (the src/rokit.ts shim, already
excluded) is documented in vite.config.ts and AGENTS.md.

Coverage: statements 65.91->68.96, branches 53.42->55.88, functions
57.86->60.73, lines 65.83->68.73 (same denominators). Floors raised
63/51/55/63 -> 66/53/58/66.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures CLI entrypoint tests to run in-process (instead of spawning the built CLI) so V8 coverage correctly attributes executed code, addressing the subprocess coverage blind spot described in #63 and aligning with the sibling design referenced in the PR description.

Changes:

  • Updated CLI tests to call mainEffect(argv) in-process with console spies for cases where the subprocess boundary is not under test.
  • Documented the remaining subprocess coverage blind spot (boot test still spawns dist/rokit.mjs) in vite.config.ts and AGENTS.md, with a pointer to Vitest 5’s coverage.autoAttachSubprocess.
  • Raised V8 coverage thresholds to match the new measured baseline (with headroom).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
vite.config.ts Documents the subprocess coverage limitation and raises coverage thresholds to the new baseline.
test/cli.test.ts Introduces an in-process CLI runner for coverage-attributed tests while keeping a spawn-based boot test.
AGENTS.md Captures the testing/coverage approach as a repo “Sharp Edges” guidance note for contributors.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@altaywtf
altaywtf merged commit 70de550 into main Aug 20, 2026
3 checks passed
@altaywtf
altaywtf deleted the chore/63-subprocess-coverage branch August 20, 2026 02:42
@putio-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.4.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover subprocess-spawned CLI paths in coverage

2 participants