test_first_party_walk.py¶
tests/test_first_party_walk.py
A first-party refresh walks first-party code, and walks it once.
test_a_first_party_refresh_never_walks_inside_a_vendored_tree
None test_first_party_walk.test_a_first_party_refresh_never_walks_inside_a_vendored_tree(Path tmp_path, pytest.MonkeyPatch monkeypatch)
A first-party build walks no vendored tree, derives no full split, and walks root once.
tests/test_first_party_walk.py:119
Checks
assert outcome.get("ok"), outcomeassert vendored == [], f"a first-party refresh walked vendored trees: {vendored}"assert derives == [], f"a first-party refresh derived the full split {len(derives)} time(s)"assert walked.count(root) == 1, f"the root was walked {walked.count(root)} times, not once"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | measured | |
| REQ-DDB-CONFIG-001 | measured | test_a_first_party_refresh_never_walks_inside_a_vendored_tree → derive_sub_indexes → whole_repo_scope |
| REQ-DDB-CONFIG-004 | measured | |
| REQ-DDB-CONFIG-005 | measured | |
| REQ-DDB-CONFIG-006 | measured | |
| REQ-DDB-CONFIG-007 | measured | |
| REQ-DDB-CONFIG-008 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-INDEX-001 | measured | |
| REQ-DDB-INDEX-002 | measured | test_a_first_party_refresh_never_walks_inside_a_vendored_tree → derive_sub_indexes |
| REQ-DDB-INDEX-003 | measured | |
| REQ-DDB-INDEX-004 | measured | |
| REQ-DDB-INDEX-005 | measured | |
| REQ-DDB-INDEX-006 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-INDEX-008 | measured | |
| REQ-DDB-INDEX-009 | measured | |
| REQ-DDB-INDEX-010 | measured | |
| REQ-DDB-INDEX-011 | measured | |
| REQ-DDB-MCP-001 | measured | test_a_first_party_refresh_never_walks_inside_a_vendored_tree → build_server |
| REQ-DDB-MCP-003 | measured | |
| REQ-DDB-MCP-004 | measured | test_a_first_party_refresh_never_walks_inside_a_vendored_tree → build_server → _refusal_as_tool_error |
| REQ-DDB-PIPE-001 | measured | |
| REQ-DDB-PIPE-003 | measured | |
| REQ-DDB-PIPE-004 | measured | |
| REQ-DDB-PIPE-005 | measured | |
| REQ-DDB-PIPE-006 | measured | |
| REQ-DDB-PIPE-007 | measured | |
| REQ-DDB-PIPE-008 | measured | |
| REQ-DDB-PIPE-009 | measured | |
| REQ-DDB-PIPE-010 | measured | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-PIPE-012 | measured | |
| REQ-DDB-PIPE-013 | measured | |
| REQ-DDB-PIPE-014 | measured | |
| REQ-DDB-PIPE-015 | measured | |
| REQ-DDB-QUERY-003 | measured | |
| REQ-DDB-QUERY-011 | measured | |
| REQ-DDB-SCHEMA-001 | measured | |
| REQ-DDB-SCHEMA-002 | measured | |
| REQ-DDB-SCHEMA-003 | measured | |
| REQ-DDB-SCHEMA-004 | measured | |
| REQ-DDB-SCHEMA-005 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-007 | measured | |
| REQ-DDB-SCHEMA-009 | measured | |
| REQ-DDB-SCHEMA-011 | measured | |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-013 | measured | |
| REQ-DDB-SCHEMA-014 | measured | |
| REQ-DDB-SCHEMA-015 | measured | |
| REQ-DDB-WIKI-034 | measured | test_a_first_party_refresh_never_walks_inside_a_vendored_tree → build_server → _register_prompts |
| REQ-DDB-WIKI-054 | measured |
Source · 39 lines
def test_a_first_party_refresh_never_walks_inside_a_vendored_tree(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""THE COST, PINNED STRUCTURALLY. Timing a small fixture proves nothing about boost, but the
walk roots do: a first-party refresh that lists a directory under `deps/` as a walk root has
paid for a vendored tree's size. Also asserted: the repository root is walked once per
refresh, not once per question asked of it.
@brief A first-party build walks no vendored tree, derives no full split, and walks root once.
@version 1
"""
root = _nested_split_repo(tmp_path)
registry = st.TargetRegistry(tmp_path / "state")
_mcp, state = build_server(registry)
first_party = registry.register(root, FIRST_PARTY_INDEX)
registry.note_derived(str(root), tuple(s.name for s in derive_sub_indexes(root)))
walked: list[Path] = []
derives: list[Path] = []
real_walk, real_derive = scope._nested_repos_under, scope.derive_sub_indexes
def _walk(input_root: Path) -> list[Path]:
walked.append(Path(input_root))
return real_walk(input_root)
def _derive(repo_root: Path) -> list[scope.SubIndex]:
derives.append(Path(repo_root))
return real_derive(repo_root)
monkeypatch.setattr(scope, "_nested_repos_under", _walk)
monkeypatch.setattr(scope, "derive_sub_indexes", _derive)
outcome = state._run_build(first_party, None, "from-guard", None, None, False)
assert outcome.get("ok"), outcome
vendored = [p for p in walked if p != root and (root / "deps") in (p, *p.parents)]
assert vendored == [], f"a first-party refresh walked vendored trees: {vendored}"
assert derives == [], f"a first-party refresh derived the full split {len(derives)} time(s)"
assert walked.count(root) == 1, f"the root was walked {walked.count(root)} times, not once"1 more lines, not shown
Activity · 18 steps
test_the_cheap_first_party_split_equals_the_derived_one
None test_first_party_walk.test_the_cheap_first_party_split_equals_the_derived_one(Path tmp_path)
first_party_sub_index matches derive_sub_indexes' first-party entry exactly.
tests/test_first_party_walk.py:94
Called by none
Calls _commit, _nested_split_repo, derive_sub_indexes, first_party_sub_index
Checks
assert [s.name for s in derived][0] == FIRST_PARTY_INDEXassert scope.first_party_sub_index(root) == derived[0]assert scope.first_party_sub_index(plain) is None, ("an unsplit repository has no first-party part" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_cheap_first_party_split_equals_the_derived_one → derive_sub_indexes → whole_repo_scope |
| REQ-DDB-INDEX-002 | measured | test_the_cheap_first_party_split_equals_the_derived_one → derive_sub_indexes |
Source · 25 lines
def test_the_cheap_first_party_split_equals_the_derived_one(tmp_path: Path) -> None:
"""THE EQUIVALENCE THE SHORTCUT RESTS ON. If `first_party_sub_index` and
`derive_sub_indexes(...)[0]` ever disagree, a refresh indexes a different first-party scope
from the one the full split names. That is a wrong index, not a slow one.
@brief first_party_sub_index matches derive_sub_indexes' first-party entry exactly.
@version 1
"""
root = _nested_split_repo(tmp_path)
derived = derive_sub_indexes(root)
assert [s.name for s in derived][0] == FIRST_PARTY_INDEX
assert scope.first_party_sub_index(root) == derived[0]
plain = tmp_path / "plain"
plain.mkdir()
(plain / "a.c").write_text("int a(void) { return 0; }\n")
_commit(plain)
assert scope.first_party_sub_index(plain) is None, (
"an unsplit repository has no first-party part"
)
@needs_git
@pytest.mark.skipif(shutil.which("doxygen") is None, reason="asserted against a real build")