test_robustness_integration.py¶
tests/integration/test_robustness_integration.py
Build-pipeline robustness to imperfect real-world source.
test_build_survives_malformed_source_file
None test_robustness_integration.test_build_survives_malformed_source_file(Path guard_repo, Path tmp_path)
A repo containing an unparseable source file still builds from the rest.
tests/integration/test_robustness_integration.py:121
Checks
assert indexed, "the build produced no functions at all"assert (SIBLING_FILE, SIBLING_FUNCTION) in indexedassert (VICTIM, VICTIM_SURVIVING_FUNCTION) in indexed
Result: passed
Verifies
Source · 21 lines
def test_build_survives_malformed_source_file(guard_repo: Path, tmp_path: Path) -> None:
"""One garbage-tailed C file must not fail the whole build — doxygen stops at
the garbage and tree-sitter is error-tolerant, so the valid files (in that
file and every other) still extract into a usable db.
@brief Malformed source degrades gracefully, not fatally.
@version 2
"""
doxyfile = guard_repo / "Doxyfile"
doxyfile.write_text(DOXYFILE_TEXT, encoding="utf-8")
victim = guard_repo / VICTIM
victim.write_text(victim.read_text(encoding="utf-8") + GARBAGE_TAIL, encoding="utf-8")
db = _build_minimal(guard_repo, tmp_path / "out.db", doxyfile)
indexed = _indexed_functions(db)
assert indexed, "the build produced no functions at all"
# Every other file in the same INPUT root still extracted...
assert (SIBLING_FILE, SIBLING_FUNCTION) in indexed
# ...and so did the valid part of the corrupted file itself.
assert (VICTIM, VICTIM_SURVIVING_FUNCTION) in indexed1 more lines, not shown