Tests unter git rebase --exec schreiben nicht ins Repo #51

Open
torben wants to merge 2 commits from 50-git-test-isolation into main
pull from: 50-git-test-isolation
Owner

Closes #50

Zusammenfassung

Anlass ist der Vorfall aus PR #49: Unter git rebase --exec haben Tests mit git im echten Repo geschrieben.

  1. Isolate git environment for all tests: tests/conftest.py entfernt in pytest_configure (vor der Sammlung, also auch vor Session-Fixtures und Code beim Import) jede Variable GIT_*. Übrig bleiben nur GIT_CONFIG_GLOBAL=/dev/null und GIT_CONFIG_NOSYSTEM=1. tests/evals/conftest.py entfällt. tests/test_git_isolation.py prüft die Regel.
  2. Run /build per-commit checks without inherited GIT_DIR: Der Prüfbefehl in /build (Abschnitt 4, Schritt 1) läuft unter env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE sh -c "<checks>", dazu ein Hinweis zur Quotierung von <checks>.

Abweichung vom Entwurf, nach /code-review: Statt den Fixture zu verschieben, werden alle GIT_*-Variablen beim Start von pytest entfernt. Damit sind auch git-Konfiguration aus git -c (GIT_CONFIG_PARAMETERS, z. B. core.hooksPath) und künftige Variablen abgedeckt. tests/conftest.py importiert nichts mehr aus chemenu.evals. Der Text des ersten Commits beschreibt noch das Verschieben; ein Force-Push zur Korrektur wurde nicht freigegeben.

Bewusst offen (Reviewer, niedrig): Die Hülle in /build entfernt nur die drei Repo-Variablen. Für pytest gleicht tests/conftest.py das aus; Checks außerhalb von pytest, die git aufrufen, gibt es derzeit nicht.

Prüfnachweis

GIT_DIR=/nonexistent GIT_WORK_TREE=/nonexistent GIT_INDEX_FILE=/nonexistent uv run pytest -q && grep -q 'env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE' .claude/skills/build/SKILL.md

Ergebnis: 513 passed, grep trifft.

Gegenproben:

  • Zusätzlich mit GIT_CONFIG_PARAMETERS und GIT_COMMON_DIR gesetzt: grün.
  • Mit nur GIT_DIR=/nonexistent und dem alten Fixture: der Test scheitert.
  • Jeder Commit wurde mit dem neuen exec-Befehl geprüft (pre-commit, pyright, pytest).
  • Danach im lokalen Repo kein Tag, core.bare=false.

Reviewer: alle vier Kriterien erfüllt.

🤖 Generated with Claude Code

Closes #50 ## Zusammenfassung Anlass ist der Vorfall aus PR #49: Unter `git rebase --exec` haben Tests mit git im echten Repo geschrieben. 1. **Isolate git environment for all tests**: `tests/conftest.py` entfernt in `pytest_configure` (vor der Sammlung, also auch vor Session-Fixtures und Code beim Import) jede Variable `GIT_*`. Übrig bleiben nur `GIT_CONFIG_GLOBAL=/dev/null` und `GIT_CONFIG_NOSYSTEM=1`. `tests/evals/conftest.py` entfällt. `tests/test_git_isolation.py` prüft die Regel. 2. **Run /build per-commit checks without inherited GIT_DIR**: Der Prüfbefehl in `/build` (Abschnitt 4, Schritt 1) läuft unter `env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE sh -c "<checks>"`, dazu ein Hinweis zur Quotierung von `<checks>`. Abweichung vom Entwurf, nach `/code-review`: Statt den Fixture zu verschieben, werden alle `GIT_*`-Variablen beim Start von pytest entfernt. Damit sind auch git-Konfiguration aus `git -c` (`GIT_CONFIG_PARAMETERS`, z. B. `core.hooksPath`) und künftige Variablen abgedeckt. `tests/conftest.py` importiert nichts mehr aus `chemenu.evals`. Der Text des ersten Commits beschreibt noch das Verschieben; ein Force-Push zur Korrektur wurde nicht freigegeben. Bewusst offen (Reviewer, niedrig): Die Hülle in `/build` entfernt nur die drei Repo-Variablen. Für pytest gleicht `tests/conftest.py` das aus; Checks außerhalb von pytest, die git aufrufen, gibt es derzeit nicht. ## Prüfnachweis ```shell GIT_DIR=/nonexistent GIT_WORK_TREE=/nonexistent GIT_INDEX_FILE=/nonexistent uv run pytest -q && grep -q 'env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE' .claude/skills/build/SKILL.md ``` Ergebnis: 513 passed, `grep` trifft. Gegenproben: - Zusätzlich mit `GIT_CONFIG_PARAMETERS` und `GIT_COMMON_DIR` gesetzt: grün. - Mit nur `GIT_DIR=/nonexistent` und dem alten Fixture: der Test scheitert. - Jeder Commit wurde mit dem neuen `exec`-Befehl geprüft (pre-commit, pyright, pytest). - Danach im lokalen Repo kein Tag, `core.bare=false`. Reviewer: alle vier Kriterien erfüllt. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
torben added this to the M2 Testkorpus und Evals milestone 2026-12-05 06:16:36 +00:00
torben added the
kind
bug
label 2026-12-05 06:16:36 +00:00
torben added 2 commits 2026-12-05 06:16:36 +00:00
Move the _isolated_git fixture to tests/conftest.py so git rebase --exec
cannot leak GIT_DIR into any test; add a test outside tests/evals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Run /build per-commit checks without inherited GIT_DIR
CI / checks (pull_request) Successful in 1m6s
115d3fb734
git rebase --exec exports GIT_DIR, so tests calling git wrote into the
repo. Wrap the check command with env -u.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
All checks were successful
CI / checks (pull_request) Successful in 1m6s
Required
Details
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 50-git-test-isolation:50-git-test-isolation
git checkout 50-git-test-isolation
Sign in to join this conversation.