Commit 09ecc10
committed
test(e2e): cover cow.rs symlink/hardlink/stage-write error arms
Four new direct-dispatch tests in e2e_safety_internals.rs that
exercise cow.rs's `?` propagation arms via the pub
`break_hardlink_if_needed` API. Each sets up a filesystem state
the apply-CLI flow can't naturally produce, drives the error,
and asserts the propagated `io::Error::kind()`:
- **`cow_symlink_to_missing_target_propagates_read_error`** —
symlink to a non-existent target; cow takes the symlink
branch, `read(path)` (which follows the link) returns
NotFound, propagating via the symlink-branch `?` arm.
Covers cow.rs:66.
- **`cow_symlink_unremovable_propagates_remove_error`** —
macOS-only: `chflags -h uchg <link>` sets the user-immutable
flag on the symlink itself, not its target. `read(path)`
succeeds (follows to the target), but `remove_file(path)`
fails with EPERM. Covers cow.rs:70.
- **`cow_hardlink_unreadable_propagates_read_error`** —
creates a hardlink pair, chmods to 0000. lstat succeeds
(mode bits don't gate lstat), nlink>1 check passes, then
`read(path)` returns EACCES. Covers cow.rs:84. Skipped
under uid 0 (root bypasses mode bits).
- **`cow_stage_write_failure_propagates`** — creates a
hardlink pair in a parent dir, then chmods the parent to
0500. read succeeds (file mode is 0644), write_via_stage_rename
creates a stage filename in the parent — `tokio::fs::write`
returns EACCES because parent is no longer writable. Covers
cow.rs:111. Skipped under uid 0.
Coverage delta on `patch/cow.rs` regions: 88.89% → 93.83%. The
remaining 5 regions are:
- **cow.rs:71** — `write_via_stage_rename(path,target_bytes).await?`
in the symlink branch. Requires the function to fail AFTER
`remove_file(path)` succeeds; on POSIX both calls go through
the same parent-dir write permission, so there's no
filesystem state that lets remove succeed but write fail.
- **cow.rs:97, 105** — `.unwrap_or_else` defaults on
`path.parent()` and `path.file_name()`. Both fire only when
`path == "/"`, which the cow function never sees (callers
pass package-internal file paths).
- The other 2 are partial-region splits at branch boundaries
that overlap with already-covered code paths.
Workspace test sweep: green under `cargo test --workspace --all-features`.
Assisted-by: Claude Code:claude-opus-4-71 parent 5c9a5fb commit 09ecc10
1 file changed
Lines changed: 167 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 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 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
216 | 383 | | |
217 | 384 | | |
218 | 385 | | |
| |||
0 commit comments