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

Show on the map →

Called by none

Calls _build_minimal, _indexed_functions

Checks

  • assert indexed, "the build produced no functions at all"
  • assert (SIBLING_FILE, SIBLING_FUNCTION) in indexed
  • assert (VICTIM, VICTIM_SURVIVING_FUNCTION) in indexed

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-019measured
REQ-DDB-GUARD-024measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
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 indexed

1 more lines, not shown

Activity · 9 steps
lines 129–129doxyfile = guard_repo / "Doxyfile"lines 130–130doxyfile.write_text(DOXYFILE_TEXT, encoding="utf-8")lines 131–131victim = guard_repo / VICTIMlines 132–132victim.write_text(victim.read_text(encoding="utf-8") + GARBAGE_TAIL, encoding="utf-8")lines 134–134db = _build_minimal(guard_repo, tmp_path / "out.db", doxyfile)lines 135–135indexed = _indexed_functions(db)lines 137–137assert indexed, "the build produced no functions at all"lines 139–139assert (SIBLING_FILE, SIBLING_FUNCTION) in indexedlines 141–141assert (VICTIM, VICTIM_SURVIVING_FUNCTION) in indexed