Repository navigation
Skip permission-denial unit tests when run as root - #2058
Conversation
Four socket-patch-core unit tests make a directory read-only and assert that a write or removal fails. Root ignores permission bits, so under uid 0 (dev containers, cloud agent sandboxes, root CI images) the operation succeeds and the tests fail on a clean checkout: patch::copy_tree::relax_loop_must_not_traverse_symlinked_root patch::redirect::vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry vendor::pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched vendor::pypi_requirements::wire_failure_rolls_back_already_written_files Give them the same geteuid() == 0 early return that the pnpm_lock, bun_lock and composer_lock permission tests already use. GitHub-hosted and Depot runners are non-root, so CI still runs every assertion. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSKziH186vNriv2dbS
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Assertions and test setup are unchanged. The guard matches the pattern already used elsewhere in this crate (e.g. lockfile tests). CI and normal non-root runs still execute these tests; only root environments (common dev containers / sandboxes) skip them, fixing false failures without weakening checks where Reviewed by Cursor Bugbot for commit 05a92bc. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 05a92bc. Configure here.
|
Ready for review at
Generated by Claude Code |
Final review briefWhat it does: Four unit tests make a directory Risk: low. No production code changes. The guard is the same one Look here:
Verified:
Changes I made: none. Open questions: none. Auto-merge is armed, so approving sends this PR straight to the merge queue. Generated by Claude Code |
Problem
CI is healthy this run. The merge queue is empty, every merge_group run since 11-10 passed, main's latest push run and today's nightly (42967443938) are green, and nothing is queued or in progress. The only red PR run in the last day (42916092136, #2052) was a real
command_module_layeringfailure from that PR's own change. So this run takes a priority-4 robustness target in the same class as #2054–#2057: unit tests that pass only because of how CI's environment is set up.#2057 lists 4 tests that fail on a clean
origin/maincheckout in every env row. I reproduced them on c09cb0e withcargo test -p socket-patch-core --libas uid 0, the default user in dev containers and cloud agent sandboxes:Root cause
Each test makes a directory
0o555and asserts that a write or removal inside it fails. Root ignores permission bits, so the operation succeeds.Fix
Each of the 4 tests now returns early under
libc::geteuid() == 0, the same guard the permission tests inpnpm_lock,bun_lockandcomposer_lockalready use. No assertion changes. 12 added lines, test code only.Proof
cargo test -p socket-patch-core --libgives 7692 passed, 0 failed.cargo clippy --locked -p socket-patch-core --all-features -- -D warnings(CI's command) is clean.--testsreports no lint in a touched file. Its existing lints are in other targets, such ascrawler_ruby_e2e.--checkon the 4 touched files is clean.Where the tests still run
GitHub-hosted and Depot runners run as non-root. That's why these tests pass in CI today, and every assertion still runs there on every PR, in the merge queue and on main. Only root runs skip them, and under root the assertions can't hold anyway.
Generated by Claude Code
Generated by Claude Code