Repository navigation
test(xtask): close the last unguarded cwd read and make with_repo_cwd panic-safe (#2186) - #2204
Conversation
…_repo_cwd panic-safe (#2186) Follow-up to #2194/#2201. A full audit of the xtask suite (1213 tests, also run green from a foreign cwd) found one remaining test reading repo-relative fixture paths without the cwd write guard: recommendation_calibration_json_and_markdown_are_structured passed only because resolve_root_path falls back to workspace_root() when ./fixtures/... is missing — a concurrent with_temp_cwd test whose temp tree happens to contain a matching relative path would make the fallback pick the wrong tree. Guard it like its two siblings. Also make with_repo_cwd restore the process cwd on panic (catch_unwind, mirroring with_temp_cwd) so a panicking guarded body cannot leak the repo-root cwd into every other cwd-sensitive test in the process.
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Closes the residual #2186 audit. After #2194 and #2201, a full inventory of the xtask suite (1185 test functions; the compiled suite of 1213 tests also passes from a foreign cwd) found exactly one remaining test that reads repo-relative fixture paths without the cwd write guard:
recommendation_calibration_json_and_markdown_are_structured(xtask/src/reports/recommendation.rs) — it passed only becauseresolve_root_pathfalls back toworkspace_root()when./fixtures/...is missing. A concurrentwith_temp_cwdtest whose temp tree happens to contain a matching relative path would make the fallback pick the wrong tree. It now holdsacquire_test_cwd_write_guard()like its two sibling tests (test(xtask): serialize recommendation fixture cwd access (#2186) #2194's pattern).Also hardens the guard helper itself:
with_repo_cwd(xtask/src/tests.rs) now restores the process cwd viacatch_unwindwhen the guarded body panics, mirroringwith_temp_cwd. Previously a panicking body leaked the repo-root cwd (and the write guard's protection) into every other cwd-sensitive test in the process.Evidence
cargo test -p xtask— 1213 passed, 0 failedcargo clippy -p xtask --all-targets -- -D warnings— cleancargo fmt --check -p xtask— cleancargo xtask precommit— cleanNon-goals
run_with_repo_root_cwd(production twin,main.rs): the test lock iscfg(test)and cannot cover it; tests exercising those commands already hold the write guard themselves.Refs #2186