Merge pull request 'fix(tests): unset hook-exported git env before running suites' (#175) from fix/run-tests-git-env into main

Reviewed-on: Defame1297/holocron#175
This commit was merged in pull request #175.
This commit is contained in:
Defame1297 committed 2026-11-13 16:05:58 +00:00
commit ff128df074
2 files changed
+12

No files matched your search

+4
View File
@@ -141,3 +141,7 @@ The pre-push `run-tests` failed 2 of 3 full runs, on a different suite each time
## 2026-09-16 — A static guard covers exactly the spellings its regex models
The guard added above (`tests/test-no-pipefail-early-exit-grep.sh`) reported the tree clean the day it landed, and the tree was not clean. Its pattern could not see a multi-stage pipeline (`echo x | filter | grep -q y`), a pipeline wrapped after a trailing `|`, or `set -o errexit -o pipefail` — the last a file-level miss that silently skipped every site in that file. Five live vulnerable sites sat in `tests/test-apm-current-hook.sh` while the suite reported green, and the fixtures carried 4 of the 12 vulnerable spellings that turned out to exist. A clean verdict from a static scanner is a claim about its regex, not about the tree. Fix: before trusting one, enumerate the spellings of the defect and measure the miss surface against them; and write the scanner's remit and its known false-positive shapes into the gate's own documentation, so the next reader knows what the green covers.
## 2026-11-13 — Hook-exported GIT_DIR turned test fixtures loose on the real repo
Under the `run-tests` pre-push hook, git exports `GIT_DIR` to the hook, so a bats fixture's `git -C "$tmp" init/commit/update-ref` hit this repo instead of its temp dir: 84 failures, `core.bare=true` and an emptied index on every push. The 2026-07-05 "repo root is a bare checkout" entry was likely this bug's symptom, not the repo's real shape. Fix: `tests/run-tests.sh` unsets git's repo-locating env vars before any suite runs. Rule: a test that builds its own repo must never inherit the caller's git environment.
+8
View File
@@ -33,6 +33,14 @@
# TEST_DIR — override root to search for test-*.sh (default: REPO_ROOT); used by tests.
set -euo pipefail
# Git exports GIT_DIR (and can export GIT_WORK_TREE / GIT_INDEX_FILE) to the
# hooks it runs, so under the run-tests pre-push hook every `git -C "$tmp" ...`
# a fixture runs resolves to THIS repo, not the temp one -- the
# validate-provenance-skill.bats commit_as_base helper flipped core.bare=true and
# emptied the index here on every push. Suites build their own throwaway repos;
# none of them may inherit the caller's.
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BATS="$REPO_ROOT/tests/run-bats.sh"
BATS_ONLY=false