test_the_registry_holds_sub_indexes_of_one_root

Tests › tests/test_named_targets.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE FIELD THAT MAKES THE COMPOSITE KEY SAFE is `repo_path` inside the record. `targets()` used to reconstruct a Target's repo_path FROM THE KEY, which is correct while the key is a bare path and wrong the moment it carries a name — the result would be a path that does not exist, handed to `Path()` and stamped into replies as the repository that answered.

Given

  1. repo = tmp_path / "myproj"
  2. repo.mkdir()
6 more
  1. reg = TargetRegistry(home=tmp_path / "state")
  2. whole = reg.register(repo)
  3. first = reg.register(repo, name="first-party")
  4. vendor = reg.register(repo, name="llama-cpp")
  5. loaded = {t.slug: t for t in reg.targets()}
  6. for allocated in (whole, first, vendor): back = loaded[allocated.slug] assert back.repo_path == str(repo.resolve()), ( f"{allocated.slug} reloaded with repo_path {back.repo_path!r} — a composite key " "leaked into a field that is used as a filesystem path" ) assert back.name == allocated.name assert Path(back.db_path).parent.is_dir(), "the db directory was not created"
→

When

  1. —
→

Then

  1. ✓ len(loaded) equals 3

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.

thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 2 of 142 steps

… 31 earlier steps

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/scope.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pytry (line 1664)tryopt (line 1666)optopt (line 352)opt_first_build_worker32. first_party_sub_index → _gitignored_paths32_gitignored_paths33. _first_build_worker → target_for33target_for34. target_for → _safe_index_name34_safe_index_name▶ test enters35. target_for → state_home35state_home36. _first_build_worker → _run_build36_run_build37. _run_build → nested_tree_cache37nested_tree_cache

… 105 later steps

4 more

tests/test_named_targets.py:145 · its file's page

What it checks (4)

  1. assert len(loaded) == 3, f"expected three records, got {sorted(loaded)}" not attributed
  2. assert back.repo_path == str(repo.resolve()), ( f"{allocated.slug} reloaded with repo_path {back.repo_path!r} — a composite key " "leaked into a field that is used as a filesystem path" ) not attributed
  3. assert back.name == allocated.name not attributed
  4. assert Path(back.db_path).parent.is_dir(), "the db directory was not created" not attributed

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.

Also reaches 1 requirement

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