Commit 2b62944
authored
## Summary
Hermetic bats coverage for the permission scenarios that have been the
most active bug surface in the recent worktree-cmd PRs (#833, #836,
#838). Pure test scaffolding — no production code changes.
## What's added
Four cases in `tests/bats/openemr-cmd/mountpoint_precreate.bats`:
1. **Empty non-writable + non-writable parent → probe fails.** The
probe-loosening rule from #838 ("empty + parent writable = rmdir-able")
requires BOTH conditions; guards against accidentally accepting a case
where the parent's perms would block the rmdir too.
2. **Unreadable dir (mode 0000) → probe fails conservatively.** When we
can't `[[ -r && -x ]]` the dir, we can't verify emptiness via `find`;
the probe must treat it as blocking (rm could silently leave content
behind otherwise).
3. **Multiple unwritable dirs (one empty-removable, one non-empty) →
probe fails on the non-empty one.** Early-termination correctness: the
probe must evaluate each unwritable dir against the empty-removable rule
rather than failing on the first unwritable it sees regardless of
removability.
4. **Reproducer for the multi-3 CI failure in #836:** stage
`ccdaservice/packages/oe-cqm-service/node_modules` as empty 0555 — the
exact path + state that broke pre-loosening. Confirms BOTH that
pre-create populates the path AND that the loosened probe accepts the
simulated post-volume-purge state. Pins the bug as a regression guard
against future drift.
## Why now
The permission-bug class has surfaced repeatedly across recent PRs
(apache uid mismatch, docker daemon root-owned mount-points, probe
over-strictness). Each fix added defensive logic; this PR turns those
scenarios into bats that fail loudly if any future refactor breaks the
invariants. The reproducer in particular locks down the specific bug
from #836 so it can't silently regress.
## What this PR can't pin
The bats simulates the FILESYSTEM STATE (root-owned-empty via chmod
0555/0000) but not the CAUSE (docker daemon creating dirs as root,
apache chowning bind mount). The real-docker e2e job in
`test-bats-openemr-cmd-real-docker.yml` covers the cause-side
end-to-end. The two are complementary.
## Test plan
- [ ] BATS openemr-cmd (ubuntu-22.04) and (macos-14) pass — the new 4
tests + existing 12 in mountpoint_precreate.bats
- [ ] No other workflow effects (no production code changes; the
existing real-docker e2e jobs run unchanged)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved handling of `worktree remove` when mount points or
directories are not writable.
* Added coverage ensuring the “empty directory” exemption is not used
when the parent is also non-writable.
* Added conservative behavior checks for effectively
unreadable/unenterable directories, preventing unsafe verification.
* Strengthened multi-candidate evaluation when multiple unwritable
directories exist, ensuring the correct failure is surfaced.
* Reproduced and protected a regression so removal succeeds for an
empty, non-writable mount point.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 82bf49f commit 2b62944
1 file changed
Lines changed: 99 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 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 | + | |
0 commit comments