fix(test): add HOME temp-dir safety guard to all test files (#908)
Add a prefix check (HOME starts with ${BATS_TEST_DIRNAME}/tmp-) before
any rm -rf in setup(), teardown(), and teardown_file() across 35 test
files. This prevents accidentally deleting the real home directory if
setup_file() fails to redirect HOME to a mktemp dir.
The guard follows a uniform pattern:
- setup(): check + FATAL message + return 1
- teardown_file(): conditionally rm -rf only if HOME matches
- teardown(): same conditional guard
Also fixes brew_uninstall.bats missing ORIGINAL_HOME guard on restore. G
guobosheng committed
d4555218525ced242d50ea34cefb251207e1b577
Parent: 603ccd3
Committed by GitHub <noreply@github.com>
on 5/18/2026, 12:54:33 AM