test(tar-xz): wrap defensive-unreachable branches with v8 ignore start/stop#123
Merged
Conversation
…t/stop Six call-sites are guarded by checks that TypeScript's strict mode (noUncheckedIndexedAccess + typed errors) requires but cannot fire at runtime under current invariants. Suppress them from coverage so the metrics reflect only paths that real tests can exercise. - file.ts: ELOOP on POSIX writeFile (O_NOFOLLOW vs ensureSafeTarget), ENOENT on the unlink-after-failed-open race, EEXIST on the wx-retry TOCTOU re-open, ENOENT on the unlink-before-link race for hardlinks, and the Win32 best-effort chmod/utimes catch arms. All five mirror the PR #114 Win32 TOCTOU hardening contract — the contract is locked by the adversarial review and SECURITY.md scenarios; race windows are too flaky for unit tests. - tar-parser.ts: parseHeader === null after isEmptyBlock — the prior empty-block check guarantees the header parses successfully. - xz-helpers.ts: '!unxzStream.destroyed' early-return guard inside the AsyncIterable's finally block — the fully-iterated path always destroys before finally runs, so the falsy arm is only hit on early generator.return() (not exercised by current tests; stream is destroyed idempotently anyway). - checksum.ts: compound parseOctal condition split so only the noUncheckedIndexedAccess-required 'byte === undefined' arm is suppressed. The reachable 'byte === 0 || byte === 0x20' continues to count toward coverage. Coverage delta on tar-xz: statements 82.05 -> 86.96; xz-helpers.ts reaches 100. Real test cases for the still-uncovered EACCES, filter, and malformed-archive paths will land in a follow-up PR. 707 tests 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 six defensive-unreachable branches in tar-xz so coverage reflects only paths real tests can hit. The simpler EACCES / filter / malformed-archive paths that ARE reachable will land as real tests in a follow-up PR.
Per-line classification
file.tswriteFileEntryPosix L268-270 (ELOOP)file.tsopenFileExclusive L322 (ENOENT on unlink)file.tsopenFileExclusive L327-334 (EEXIST on retry)file.tswriteFileEntryWin32 L370-373/L375-379file.tsextractHardlinkEntry L241 (ENOENT on unlink)tar-parser.tsparseNextHeader L107-108xz-helpers.tsL65 (!unxzStream.destroyed)checksum.tsparseOctal L89 (byte === undefined)ifsplit so only the defensive arm is suppressed ; reachablebyte === 0 || byte === 0x20arm continues to count.Lines NOT suppressed (deferred to follow-up real tests)
extract.tsL70-72, L78-88file.tsL223, L225, L231-234, L315, L335tar-parser.tsL254, L338, L361format.tsL101, L170-175create.tsL88-104Coverage delta
xz-helpers.tsDiff
4 files, +21 / -2.
Gates
pnpm install --frozen-lockfile: EXIT 0pnpm --filter tar-xz build: EXIT 0pnpm type-check: EXIT 0pnpm exec biome check .: EXIT 0, 0 warningspnpm test: 707 pass / 0 fail / 3 skippedTest plan