test(tar-xz): close remaining coverage gaps to 100% lines#125
Merged
Conversation
Pair real test cases with v8 ignore wraps for the genuinely defensive branches that PR-γ missed and one Win32 TOCTOU rethrow that landed after PR-γ scope was closed. Tests added (13 cases in test/coverage-final.spec.ts): - create.ts AsyncIterable source — async generator and single-chunk variants ; ArrayBuffer source — locks the resolveSource contract. - extract.ts zero-byte entry — bytes() returns the cached empty Uint8Array ; second call hits the cache. - file.ts hardlink edges — forward-reference (lstat ENOENT swallowed, link() ENOENT propagates), symlink-as-source rejection, symlink-ancestor rejection, EACCES propagation on POSIX. - tar-parser.ts truncated archive — three phases covered (mid-header 256-byte XZ buffer, mid-body during list() SKIP, mid-padding with size=300 entry). All assert 'Unexpected end of archive'. v8 ignore wraps in extract.ts (4 sites): - drainSkippedEntry TAR_PARSER_INVARIANT rethrow — corrupt parser state unreachable via public API. - makeDataGen concurrent-iteration guard — makeTarEntryWithData calls dataPull() exactly once per entry. - extract() stray-chunk invariant — parseTar never emits chunk before entry. - bytes() overflow guard — parseTar clips chunks at bytesRemaining, so over-delivery cannot happen via extract(). v8 ignore wrap in file.ts (1 site): - openFileExclusive Win32 TOCTOU retry rethrow (line 343) — same race-window pattern as the other PR #114 hardening guards. Coverage: - tar-xz lines: 95.33% → 100%. - tar-xz branches: 89.45% → 92.53% (v8-ignored bodies leave the condition counter active; only /* v8 ignore next */ would suppress it, which the project convention forbids). - create.ts, extract.ts, tar-parser.ts, file.ts: all at 100% lines. tar-xz tests: 190 → 203 passing (+13), 3 skipped unchanged. Full workspace 707 → 720 passing, 0 failing.
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
Final tar-xz coverage push : real tests for the genuinely-untested code paths + v8 ignore wraps for the defensive branches that PR-γ left. Brings tar-xz from 95.33% to 100% lines.
Tests added (13 cases in
test/coverage-final.spec.ts)create.ts:88-104AsyncIterable sourceextract.ts:70-73zero-byte entrybytes()returns empty Uint8Array, second call hits cachefile.ts:223hardlink lstat ENOENTlink()ENOENT propagatesfile.ts:225-229symlink-as-source rejectionfile.ts:232symlink-ancestor rejectionhasSymlinkAncestorreturns truefile.ts:275EACCES on openit.skipIffor Windows / roottar-parser.ts:254mid-header truncationtar-parser.ts:338mid-body duringlist()SKIPtar-parser.ts:361mid-paddingv8 ignore wraps applied
extract.tsdrainSkippedEntry L165-169extract.tsmakeDataGen L205-210makeTarEntryWithDatacalls dataPull() exactly once per entryextract.tsextract() L299-303parseTarnever emits chunk before entryextract.tsbytes() L78-92parseTarclips chunks atbytesRemaining, so over-delivery cannot happen viaextract()file.tsopenFileExclusive L343Smart fixture finding
list()andextract()callstreamXz()internally — raw TAR bytes passed directly fail withLZMAFormatError. All truncated-archive fixtures wrap bytes withxzSync()first. Locks the contract for future fixture writers.Coverage delta
create.tslinesextract.tslinestar-parser.tslinesfile.tslinesBranch ceiling is 92.53% because
v8 ignore start/stopsuppresses body lines but the condition's branch counter still increments. Only/* v8 ignore next */would suppress the condition, but that form is explicitly forbidden by the project convention.Diff
3 files changed, +513 / 0 :
packages/tar-xz/src/node/extract.ts: +8 (4 wraps)packages/tar-xz/src/node/file.ts: +2 (1 wrap)packages/tar-xz/test/coverage-final.spec.ts: NEW, +503 LOCGates
pnpm install --frozen-lockfile: EXIT 0pnpm --filter tar-xz build: EXIT 0pnpm type-check: EXIT 0pnpm exec biome check .: EXIT 0, 0 warningspnpm test: tar-xz 190 → 203 passing (+13), 3 skipped unchanged ; full workspace 489 root + 203 tar-xz + 63 nxz = 755 passing, 0 failTest plan