test_the_gate_and_the_index_agree_on_one_declaration

Tests › tests/test_toolchain.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE INVARIANT THAT ACTUALLY MATTERS. One `toolchain.toml` statement, two consumers: the gate asks `gate_exclusion` per file, the index asks `expand_globs` once per build. A file the gate refuses to check must be a file the index was told to exclude, or the repository's single statement means two different things depending on which half of clew read it.

Verifies REQ-DDB-PIPE-011

Given

  1. target = _write(tmp_path, "node_modules/dep/index.js", "module.exports = 1;\n")
  2. _write(tmp_path, "src/k.c")
  3. (tmp_path / "toolchain.toml").write_text('[ignore]\npaths = ["node_modules/**"]\n')
→

When

  1. config = load_toolchain_config(tmp_path)
  2. cwd = os.getcwd()
  3. os.chdir(tmp_path)
2 more
  1. try: _gate_matcher.cache_clear() gate_reason = gate_exclusion("node_modules/dep/index.js") finally: os.chdir(cwd) _gate_matcher.cache_clear()
  2. excluded = expand_globs(tmp_path, config.index_globs)
→

Then

  1. ✓ gate_reason is not None
  2. ✓ any(target == path or path in target.parents for path in excluded) holds

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) · 10 of 357 steps

… 83 earlier steps

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.pyother filesother filesother filesother filesloop (line 69)looploop (line 135)loopopt (line 178)optopt (line 184)optopt (line 98)optmain84. excluded_by → matches84matches85. validate_file → gate_exclusion85gate_exclusion86. gate_exclusion → _gate_matcher86_gate_matcher▶ test enters87–92. _gate_matcher → load_toolchain_config87load_toolchain_config +5 more93–95. all → _events93_events +2 more96. load_toolchain_config → _string_list96_string_list97–99. load_toolchain_config → _read_toml97_read_toml +2 more100. _gate_matcher → compile_globs100compile_globs101. gate_exclusion → matches101matches102. gate_exclusion → binary_file102binary_file103. validate_file → parse_source_file103parse_source_file

… 254 later steps

1 more

tests/test_toolchain.py:194 · its file's page

What it checks (2)

  1. assert gate_reason is not None, "the gate must skip it; this test is about the other half" observes gate_exclusion via gate_reason
  2. assert any(target == path or path in target.parents for path in excluded), ( f"the gate skips {target} but the index was handed no exclusion covering it: {excluded}" ) observes expand_globs via excluded

Where the product reaches it

  • main → _run → run_precommit → _validate_files → validate_file → gate_exclusion (flow)
  • main → _run → run_precommit → _validate_files → validate_file → gate_exclusion → _gate_matcher → load_toolchain_config (flow)

Call flow

test_the_gate_and_the_index_agree_on_one_declaration→_write→load_toolchain_config→gate_exclusion→expand_globs

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_and_the_index_agree_on_one_declaration · 2 checksgate_exclusionREQ-DDB-CONFIG-009 · measuredgate_exclusionbinary_fileREQ-DDB-PIPE-011 · catalogload_toolchain_config_string_listallREQ-DDB-WIKI-054 · inferred

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-011catalog1 of 3: binary_file
Also reaches 2 requirements

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