| name | setup-hook-tests | ||||
|---|---|---|---|---|---|
| description | Add or extend Bats coverage for setup-hook scripts. | ||||
| metadata |
|
- Append to the existing test file for the hook.
- Create a unique sandbox under
tests/unit/.bats-sandbox/. - Patch absolute system paths before running the hook.
- Stub commands through a test-local
stub-bindirectory. - Assert the concrete side effect, not only exit status.
Run:
bats tests/unit/
pre-commit run --all-files- The test writes outside its sandbox.
- A real
/usrhelper or absolute binary is still called. - A test asserts only that the script exits zero.
- A second test file is created for an existing hook.
Use for Bats coverage for setup hooks.
Do not use for Non-hook build scripts or full image validation.
Sandbox the hook, patch absolute paths, assert concrete side effects.
- "A shortcut is harmless." Follow the source-of-truth and verification rules instead.
- Testing against the host filesystem or asserting only exit zero.
- The selected source and focused command were checked.
- The repository default gate passes.