test_the_gate_git_path_cannot_run_the_trees_commands

Tests › tests/test_gitenv.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE SECOND HALF OF C1, MISSED BY THE FIRST PASS AND FOUND BY A TEST FOR SOMETHING ELSE. `clew.guard` deliberately shares no code with the pipeline, so it has its OWN git runner — `run_git(["git", …])` through an injectable `_default_run_command`. Routing the pipeline's five call sites through `git_argv` left all six of the gate's untouched, and the gate is the WORSE context: it runs on a developer's machine, as that developer, on whatever branch they have checked out to review.

Verifies REQ-DDB-PIPE-014

Given

  1. sentinel = tmp_path / "gate-fsmonitor-ran"
  2. root = _hostile_config_repo(tmp_path / "hostile", sentinel)
2 more
  1. (root / "src.c").write_text("int main(void) { return 0; }\n", encoding="utf-8")
  2. original = Path.cwd()
→

When

  1. try: os.chdir(root) get_staged_diff("src.c") get_file_at_revision("src.c", "HEAD") finally: os.chdir(original)
→

Then

  1. ✓ sentinel.exists() is false

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

`main` (clew/guard/main.py) · 5 of 357 steps

… 65 earlier steps

program launcherprogram launcherprogram launcherprogram launcherother filesother filesother filesother filesopt (line 1336)optalt (line 1344)altmain66–67. read_catalog_at → git_text66git_text +1 more68–69. git_argv → _no_ext_diff68_no_ext_diff +1 more70–71. read_catalog_at → _refuse_url70_refuse_url +1 more

… 156 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesloop (line 1096)loopopt (line 265)optmain228. check_fails_when_markers → marker228marker229. validate_file → get_file_at_revision229get_file_at_revision230. get_file_at_revision → run_git230run_git▶ test enters231. run_git → git_argv231git_argv232. validate_file → parse_content_for_file232parse_content_for_file233. validate_file → check_version_staleness233check_version_staleness

… 26 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyclew/guard/impact.pyother filesother filesother filesother filesopt (line 114)optopt (line 116)optmain260. _collect_changed_lines → _get_file_diff260_get_file_diff261. _get_file_diff → get_staged_diff261get_staged_diff262. get_staged_diff → run_git262run_git▶ test enters263. _get_file_diff → get_diff263get_diff264. get_diff → run_git264run_git

… 93 later steps

4 more

tests/test_gitenv.py:213 · its file's page

What it checks (1)

  1. assert not sentinel.exists(), ( "the pre-commit gate ran a command the inspected repository's own .git/config chose" ) not attributed

Where the product reaches it

  • main → _run → run_precommit → _validate_files → validate_file → get_file_at_revision (flow)
  • main → _run → run_precommit → impact_report → collect_changes → _collect_changed_lines → _get_file_diff → get_staged_diff (flow)

Call flow

test_the_gate_git_path_cannot_run_the_trees_commands→_hostile_config_repo→get_staged_diff→get_file_at_revision

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_the_gate_git_path_cannot_run_the_trees_commands · 1 checksget_staged_diffrun_gitgit_argvREQ-DDB-CONFIG-001 · measuredget_staged_diffREQ-DDB-GUARD-023 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-014catalogunknown
Also reaches 2 requirements

Its run touches their code; that is reach, not proof.