test: restore 100% coverage on root src/ (errors.ts + pool.ts defensive guards)#122
Merged
Conversation
…ve guards) Two defensive branches in root src/ were flagged as uncovered by vitest's v8 instrumentation. Both are intentional fail-closed safety nets that should remain in code (TypeScript noUncheckedIndexedAccess widens the runtime-narrowed types) but are unreachable under current invariants and so cannot be exercised by tests. - src/errors.ts:176 — 'if (msg === undefined) return Unknown LZMA error code: ...' is preceded by a bounds check on errno, so the array lookup is always defined. Wrapped with v8 ignore start/stop. - src/pool.ts:168 — 'if (item === undefined) throw Invariant violation' is preceded by a queue.length===0 early return, so shift() never returns undefined. Wrapped with v8 ignore start/stop. Per project convention the start/stop pair form is mandatory (never 'next' or 'next N' which only excludes line coverage and not branch coverage). Coverage restored across the entire repo: root src/ now 100%/100%/ 100%/100% (statements/branches/functions/lines), packages/nxz already at 100% from PR #121, packages/tar-xz unchanged. 707 tests still pass byte-identical.
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
Wrap two defensive branches with
v8 ignore start/stopto restore root src/ to 100% coverage. Both are intentional fail-closed safety nets that TypeScript'snoUncheckedIndexedAccessrequires (it widens narrowed types) but are unreachable at runtime under current invariants.Targets
src/errors.ts:176if (msg === undefined) return ...errno >= messages.lengthearly return)stringat runtime ; TS widens type but value is always definedsrc/pool.ts:168if (item === undefined) throw ...queue.length === 0early returnT | undefinedbut value is alwaysTCoverage
src/statementssrc/branchessrc/functionssrc/linesCombined with PR #121 (packages/nxz 95.2% → 100%), the entire repo is now at 100% coverage.
Gates
pnpm install --frozen-lockfile: EXIT 0pnpm build: EXIT 0pnpm type-check: EXIT 0pnpm exec biome check .: EXIT 0, 0 warningspnpm test: 707 pass / 0 fail / 3 skippedDiff
2 files, +4 / -0.
Test plan