test_incremental_pipeline.py¶
tests/integration/test_incremental_pipeline.py
An incrementally refreshed index must equal a full rebuild — THROUGH THE REAL PIPELINE.
test_an_incremental_refresh_equals_a_full_rebuild
None test_incremental_pipeline.test_an_incremental_refresh_equals_a_full_rebuild(Path tmp_path)
A pipeline-driven incremental refresh must equal a pipeline-driven full rebuild.
tests/integration/test_incremental_pipeline.py:181
Checks
assert row is not None and int(row[0]) > 0, (f"the second build did NOT take the incremental branch (splice_generation={row}), so " f"this test compares two full rebuilds and proves nothing about the splice" )assert ("pipeline_probe", "sound_play_findme", "doxygen_sqlite") in want["edges"] or any(a == "pipeline_probe" and b == "sound_play_findme" for a, b, _ in want["edges"] ), "the rebuild has no pipeline_probe -> sound_play_findme edge; the second pass is untested"assert not any("vendor" in f for f in want["indexed"]), ("the rebuild indexed the excluded vendor/ tree, so EXCLUDE_PATTERNS is not in force " "and the scope filter is untested here" )assert any("Extra" in a or "Extra" in b for a, b in want["reimplements"]), ("the rebuild has no Extra override, so the inheritance tables are untested here" )assert want["params"], ("the rebuild produced no memberdef_param rows, so comparing that table is vacuous" )assert not missing and not extra, (f"{layer}: the incrementally refreshed index disagrees with a full rebuild.\n" f" missing from incremental ({len(missing)}): {sorted(missing)[:8]}\n" f" only in incremental ({len(extra)}): {sorted(extra)[:8]}" )
Result: passed
Verifies
Source · 71 lines
def test_an_incremental_refresh_equals_a_full_rebuild(tmp_path: Path) -> None:
"""THE WIRING IS THE SUBJECT. Every call goes through `build_index`, so removing any step
from `_incremental_plan` or `_incremental_doxygen` changes this test's answer.
The incremental build reuses ONE output path across two invocations, which is what makes
the second one incremental: the sidecar beside that path holds the previous doxygen output
and the scan state. The full rebuild goes to a FRESH path, so it has no sidecar and cannot
take the splice branch at all.
@brief Incremental and full builds of one tree agree.
@return None.
@version 1
"""
root = tmp_path / "repo"
_seed(root)
incremental = tmp_path / "incremental.db"
with captured_output():
build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")
_edit(root)
with captured_output():
build_index(output=incremental, repo_root=root, doxyfile=root / "Doxyfile")
## THE NON-VACUITY GATE FOR THIS WHOLE FILE. If the second build fell back to a full run
## — no previous output, a config_sha mismatch, an exception swallowed by the fallback —
## then every comparison below passes while testing NOTHING about the splice. The sidecar's
## generation counter is the structural witness: `record_splice(reset=...)` zeroes it after
## a full build and increments it after a splice, so a positive value can only mean the
## incremental branch ran.
sidecar = sqlite3.connect(str(incremental) + ".idxcache")
try:
row = sidecar.execute(
"SELECT value FROM cache_meta WHERE key = 'splice_generation'"
).fetchone()
finally:
sidecar.close()
assert row is not None and int(row[0]) > 0, (
f"the second build did NOT take the incremental branch (splice_generation={row}), so "
f"this test compares two full rebuilds and proves nothing about the splice"
)
full = tmp_path / "full.db"
with captured_output():
build_index(output=full, repo_root=root, doxyfile=root / "Doxyfile")
got, want = _snapshot(incremental), _snapshot(full)
## NON-VACUITY, per mechanism. Each of these is a thing the pipeline had to do correctly to
## get here; if the rebuild lacks it, the comparison below cannot see that mechanism at all.
assert ("pipeline_probe", "sound_play_findme", "doxygen_sqlite") in want["edges"] or any(
a == "pipeline_probe" and b == "sound_play_findme" for a, b, _ in want["edges"]
), "the rebuild has no pipeline_probe -> sound_play_findme edge; the second pass is untested"
assert not any("vendor" in f for f in want["indexed"]), (
"the rebuild indexed the excluded vendor/ tree, so EXCLUDE_PATTERNS is not in force "
"and the scope filter is untested here"
)
assert any("Extra" in a or "Extra" in b for a, b in want["reimplements"]), (
"the rebuild has no Extra override, so the inheritance tables are untested here"
)
assert want["params"], (
"the rebuild produced no memberdef_param rows, so comparing that table is vacuous"
)
for layer in ("members", "edges", "indexed", "reimplements", "params"):
missing = want[layer] - got[layer]
extra = got[layer] - want[layer]
assert not missing and not extra, (
f"{layer}: the incrementally refreshed index disagrees with a full rebuild.\n"
f" missing from incremental ({len(missing)}): {sorted(missing)[:8]}\n"
f" only in incremental ({len(extra)}): {sorted(extra)[:8]}"
)1 more lines, not shown