Commit 8e51020
authored
test(tar-xz): close file.ts coverage partials with tests + v8 ignores (#128)
Address ten remaining partial branches in file.ts: two are real
reachable paths that get fixtures, eight are defensive guards that
get v8 ignore start/stop wraps with inline rationale.
Real tests added (2 in coverage-trivial-branches.spec.ts):
- extractSymlinkEntry early-return: a SYMLINK entry whose linkname
is a single component is silently skipped when strip=1, exercising
the if (!strippedLinkname) return; branch.
- extractHardlinkEntry early-return: same shape for hardlinks.
The coverage-trivial-branches helper buildSingleEntryTar gains an
optional linkname parameter so the tests can craft SYMLINK and
HARDLINK archives without depending on coverage-final.spec.ts.
v8 ignore wraps applied (7 sites in file.ts):
- ensureSafeName: TS-defensive 'undefined' early-return AND the
NUL-byte rejection. Discovery during this work: parseString in
tar/format.ts already terminates a name field at the first 0x00,
so any name reaching ensureSafeName cannot contain a NUL. The
guard is meaningful only for non-TAR callers and is unreachable
via the public extract path; suppress accordingly.
- hasSymlinkAncestor non-ENOENT rethrow: race-window where the
ancestor directory disappears between lstat calls; non-ENOENT
branches are EACCES/EIO that test fixtures cannot trigger.
- hasSymlinkAncestor parent === dir guard: filesystem-root
invariant; tar entries are relative paths under cwd so the loop
never reaches POSIX '/' or Windows 'C:\'.
- ensureSafeTarget non-ENOENT rethrow: race-window in the
stat-then-validate sequence.
- extractSymlinkEntry non-ENOENT rethrow on unlink: race-window
where the existing symlink disappears between ensureSafeTarget
and the unlink call.
- extractHardlinkEntry non-ENOENT rethrow on lstat: race-window
on the link source.
- openFileExclusive non-EEXIST rethrow on the first open: same
race-window class as the existing wraps in the same function;
closes the symmetry hole.
Coverage:
- file.ts branches 83.72% -> 92.85% (+9.13).
- tar-xz overall branches 92.80% -> 94.98% (+2.18).
- tar-xz lines stay 100%.
tar-xz tests: 209 pass / 3 skipped -> 211 pass / 3 skipped (+2).1 parent 2a4210a commit 8e51020
2 files changed
Lines changed: 117 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
82 | 87 | | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
85 | 92 | | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| 142 | + | |
134 | 143 | | |
| 144 | + | |
135 | 145 | | |
136 | 146 | | |
137 | 147 | | |
| |||
175 | 185 | | |
176 | 186 | | |
177 | 187 | | |
| 188 | + | |
178 | 189 | | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
| |||
220 | 232 | | |
221 | 233 | | |
222 | 234 | | |
| 235 | + | |
223 | 236 | | |
| 237 | + | |
224 | 238 | | |
225 | 239 | | |
226 | 240 | | |
| |||
316 | 330 | | |
317 | 331 | | |
318 | 332 | | |
| 333 | + | |
319 | 334 | | |
| 335 | + | |
320 | 336 | | |
321 | 337 | | |
322 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
0 commit comments