test_splice_inheritance.py

tests/integration/test_splice_inheritance.py

An edited base class keeps the classes that derive from it in OTHER files (entropic, 2.0.0).

test_a_refresh_under_strip_from_path_keeps_inheritance

None test_splice_inheritance.test_a_refresh_under_strip_from_path_keeps_inheritance(Path tmp_path)

Edit, refresh and revert under STRIP_FROM_PATH equal fresh builds.

tests/integration/test_splice_inheritance.py:134

Show on the map →

Called by none

Calls _inheritance, _pipeline, git_argv

Checks

  • assert ("compoundref", "Base>Derived") in want, f"vacuous: {want}"
  • assert _inheritance(_pipeline(root, live)) == _inheritance(_pipeline(root, fresh)), "edit"
  • assert _inheritance(_pipeline(root, live)) == want, "revert"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → report_stats
REQ-DDB-CLI-002inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → _doxygen_or_partial → _doxygen_stage → _run_doxygen_from_args → run_doxygen → doxygen_supports_sqlite3
REQ-DDB-CONFIG-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → git_argv
REQ-DDB-CONFIG-003inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-CONFIG-004measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_preprocessor
REQ-DDB-CONFIG-005measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig
REQ-DDB-CONFIG-006measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _recorded_entry_patterns → recorded_explicit
REQ-DDB-CONFIG-007measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature
REQ-DDB-CONFIG-009measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _apply_toolchain_exclusions → load_toolchain_config
REQ-DDB-GUARD-012inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → load_guard_config → read_guard_config → read_requirements_section
REQ-DDB-GUARD-019inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → apply_autobrief
REQ-DDB-INDEX-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _verify_extra_input_is_read → effective_file_patterns
REQ-DDB-INDEX-002measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → build_lock
REQ-DDB-INDEX-003measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → report_index_coverage
REQ-DDB-INDEX-004measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols
REQ-DDB-INDEX-005measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → stamp_external_provenance
REQ-DDB-INDEX-006measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → record_code_text → code_text_rows
REQ-DDB-INDEX-007measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → record_owners
REQ-DDB-INDEX-008measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_licenses
REQ-DDB-INDEX-009measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc
REQ-DDB-INDEX-010measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes
REQ-DDB-INDEX-011measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_property_keys
REQ-DDB-MCP-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _operator_excludes → meta_section
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_database
REQ-DDB-PIPE-003measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → build_call_edges
REQ-DDB-PIPE-004measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → python_entry_seeds
REQ-DDB-PIPE-005measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature
REQ-DDB-PIPE-006measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → run_rustdoc → _require_nightly_rustdoc → clean_subprocess_env
REQ-DDB-PIPE-007measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig_gates
REQ-DDB-PIPE-008measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs
REQ-DDB-PIPE-009measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → prune_dominated_fuzzy_call_edges
REQ-DDB-PIPE-010measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → build_harvest_plan → js_symbol_harvester
REQ-DDB-PIPE-013measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings
REQ-DDB-PIPE-014measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc → within_repo
REQ-DDB-PIPE-015measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_config_defaults
REQ-DDB-QUERY-003measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → mark_test_scope
REQ-DDB-QUERY-011measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads → _ensure_threads_tables
REQ-DDB-SCHEMA-001measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads
REQ-DDB-SCHEMA-002measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-003measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest
REQ-DDB-SCHEMA-005measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-006measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml
REQ-DDB-SCHEMA-007measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-009measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_event_edges
REQ-DDB-SCHEMA-011measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → extract_context_conflicts
REQ-DDB-SCHEMA-012measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest → declaration_origin
REQ-DDB-SCHEMA-013measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → import_data_model_keys
REQ-DDB-SCHEMA-014measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs → ensure_file_docs_table
REQ-DDB-SCHEMA-015measuredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_a_refresh_under_strip_from_path_keeps_inheritance → _pipeline → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols → _recover_into → all
Source · 53 lines
def test_a_refresh_under_strip_from_path_keeps_inheritance(tmp_path: Path) -> None:
    """ENTROPIC'S RERUN OF 314e4696 (7ea9724): through the real pipeline a doc-only edit to
    adapter_base.h still took compoundref 133 -> 125 and reimplements 248 -> 221, and reverting it
    left 128 / 228. entropic's Doxyfile declares `STRIP_FROM_PATH = include src`, so the cached
    master spells `include/x/base.h` as `x/base.h`; `_incremental_plan` ran `xref_closure` on that
    RAW master, where no row can match the changed file — the closure was the changed file alone,
    for xrefs too. The two-header test above has no stripping and could not see it.

    @brief Edit, refresh and revert under STRIP_FROM_PATH equal fresh builds.
    """
    root = tmp_path / "repo"
    (root / "include" / "x").mkdir(parents=True)
    (root / "src" / "x").mkdir(parents=True)
    (root / "include" / "x" / "base.h").write_text(
        "/** @brief A base. */\nstruct Base {\n  /** @brief Area. */\n  virtual int area() const;\n"
        "  virtual ~Base() {}\n};\n",
        encoding="utf-8",
    )
    (root / "src" / "x" / "derived.h").write_text(
        '#include "x/base.h"\n/** @brief A derived. */\nstruct Derived : Base {\n'
        "  /** @brief Area. */\n  int area() const override;\n};\n",
        encoding="utf-8",
    )
    (root / "Doxyfile").write_text(
        "PROJECT_NAME = strip\nINPUT = include src\nRECURSIVE = YES\nEXTRACT_ALL = YES\n"
        "FULL_PATH_NAMES = YES\nSTRIP_FROM_PATH = include src\nSTRIP_FROM_INC_PATH = include\n",
        encoding="utf-8",
    )
    import subprocess

    from clew.gitenv import git_argv

    subprocess.run(git_argv("init", "-q"), cwd=root, check=True)
    subprocess.run(git_argv("add", "-A"), cwd=root, check=True)
    subprocess.run(
        git_argv("-c", "user.email=t@t", "-c", "user.name=t", "commit", "-qm", "base"),
        cwd=root,
        check=True,
    )
    live = tmp_path / "live" / "clew.db"
    live.parent.mkdir()
    want = _inheritance(_pipeline(root, live))
    assert ("compoundref", "Base>Derived") in want, f"vacuous: {want}"

    base = root / "include" / "x" / "base.h"
    original = base.read_text(encoding="utf-8")
    base.write_text(original.replace("A base.", "A base, reworded."), encoding="utf-8")
    fresh = tmp_path / "fresh" / "clew.db"
    fresh.parent.mkdir()
    assert _inheritance(_pipeline(root, live)) == _inheritance(_pipeline(root, fresh)), "edit"

    base.write_text(original, encoding="utf-8")
    assert _inheritance(_pipeline(root, live)) == want, "revert"

1 more lines, not shown

Activity · 23 steps
lines 144–144root = tmp_path / "repo"lines 145–145(root / "include" / "x").mkdir(parents=True)lines 146–146(root / "src" / "x").mkdir(parents=True)lines 147–151(root / "include" / "x" / "base.h").write_text( "/** @brief A base. */\nstruct Base {\n /** @brief Area. */\n virtual int area() const;\n" " virtual ~Base() {}\n};\n", encoding="utf-8", )lines 152–156(root / "src" / "x" / "derived.h").write_text( '#include "x/base.h"\n/** @brief A derived. */\nstruct Derived : Base {\n' " /** @brief Area. */\n int area() const override;\n};\n", encoding="utf-8", )lines 157–161(root / "Doxyfile").write_text( "PROJECT_NAME = strip\nINPUT = include src\nRECURSIVE = YES\nEXTRACT_ALL = YES\n" "FULL_PATH_NAMES = YES\nSTRIP_FROM_PATH = include src\nSTRIP_FROM_INC_PATH = include\n", encoding="utf-8", )lines 162–162import subprocesslines 164–164from clew.gitenv import git_argvlines 166–166subprocess.run(git_argv("init", "-q"), cwd=root, check=True)lines 167–167subprocess.run(git_argv("add", "-A"), cwd=root, check=True)lines 168–172subprocess.run( git_argv("-c", "user.email=t@t", "-c", "user.name=t", "commit", "-qm", "base"), cwd=root, check=True, )lines 173–173live = tmp_path / "live" / "clew.db"lines 174–174live.parent.mkdir()lines 175–175want = _inheritance(_pipeline(root, live))lines 176–176assert ("compoundref", "Base>Derived") in want, f"vacuous: {want}"lines 178–178base = root / "include" / "x" / "base.h"lines 179–179original = base.read_text(encoding="utf-8")lines 180–180base.write_text(original.replace("A base.", "A base, reworded."), encoding="utf-8")lines 181–181fresh = tmp_path / "fresh" / "clew.db"lines 182–182fresh.parent.mkdir()lines 183–183assert _inheritance(_pipeline(root, live)) == _inheritance(_pipeline(root, fresh)), "edit"lines 185–185base.write_text(original, encoding="utf-8")lines 186–186assert _inheritance(_pipeline(root, live)) == want, "revert"

test_editing_a_base_class_keeps_its_derived_classes_in_other_files

None test_splice_inheritance.test_editing_a_base_class_keeps_its_derived_classes_in_other_files(Path tmp_path)

Cross-file inheritance survives a splice of the base's file.

tests/integration/test_splice_inheritance.py:70

Show on the map →

Called by none

Calls _inheritance, _run, include_expansion, splice_doxygen, xref_closure

Checks

  • assert ("compoundref", "Base>Derived") in want, (f"vacuous: the rebuild has no inheritance {want}" )
  • assert ("reimplements", "Derived::area>Base::area") in want, f"vacuous: no override {want}"
  • assert not report.skipped, report.skipped
  • assert _inheritance(spliced) == want, (f"subset {subset}: the splice lost cross-file inheritance — missing " f"{sorted(want - _inheritance(spliced))}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-002inferredtest_editing_a_base_class_keeps_its_derived_classes_in_other_files → _run → run_doxygen → doxygen_supports_sqlite3
REQ-DDB-INDEX-001measuredtest_editing_a_base_class_keeps_its_derived_classes_in_other_files → _run → run_doxygen
REQ-DDB-INDEX-002measuredtest_editing_a_base_class_keeps_its_derived_classes_in_other_files → splice_doxygen
REQ-DDB-PIPE-003measuredtest_editing_a_base_class_keeps_its_derived_classes_in_other_files → _run → run_doxygen → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-006measuredtest_editing_a_base_class_keeps_its_derived_classes_in_other_files → _run → run_doxygen → clean_subprocess_env
Source · 56 lines
def test_editing_a_base_class_keeps_its_derived_classes_in_other_files(tmp_path: Path) -> None:
    """THE BASE'S FILE IS THE ONLY CHANGE, and the derived class's file has no call into it — the
    shape of entropic's adapters. A full rebuild is the ground truth.

    @brief Cross-file inheritance survives a splice of the base's file.
    """
    root = tmp_path / "repo"
    (root / "include").mkdir(parents=True)
    (root / "include" / "base.h").write_text(
        "/** @brief A base. */\nstruct Base {\n  /** @brief Area. */\n  virtual int area() const;\n"
        "  virtual ~Base() {}\n};\n",
        encoding="utf-8",
    )
    (root / "include" / "derived.h").write_text(
        '#include "base.h"\n/** @brief A derived. */\nstruct Derived : Base {\n'
        "  /** @brief Area. */\n  int area() const override;\n};\n",
        encoding="utf-8",
    )
    doxyfile = tmp_path / "Doxyfile"
    doxyfile.write_text(
        f"PROJECT_NAME = inh\nINPUT = {root}\nGENERATE_SQLITE3 = YES\nEXTRACT_ALL = YES\n"
        "REFERENCED_BY_RELATION = YES\nREFERENCES_RELATION = YES\n",
        encoding="utf-8",
    )
    master = tmp_path / "master-kept.db"
    shutil.copy2(_run(doxyfile, tmp_path / "master", root), master)

    ## A DOC-ONLY EDIT TO THE BASE, as 7ea9724 was.
    base = root / "include" / "base.h"
    base.write_text(base.read_text().replace("A base.", "A base, reworded."), encoding="utf-8")
    changed = {"include/base.h"}

    truth = tmp_path / "truth-kept.db"
    shutil.copy2(_run(doxyfile, tmp_path / "truth", root), truth)
    want = _inheritance(truth)
    assert ("compoundref", "Base>Derived") in want, (
        f"vacuous: the rebuild has no inheritance {want}"
    )
    assert ("reimplements", "Derived::area>Base::area") in want, f"vacuous: no override {want}"

    subset = sorted(xref_closure(master, changed, root))
    subset_db = _run(doxyfile, tmp_path / "subset", root, subset=subset)
    extra = include_expansion(subset_db, master, changed, set(subset), root)
    if extra:
        subset = sorted(set(subset) | extra)
        subset_db = _run(doxyfile, tmp_path / "subset2", root, subset=subset)
    spliced = tmp_path / "spliced.db"
    report = splice_doxygen(master, subset_db, changed, spliced, root)

    assert not report.skipped, report.skipped
    assert _inheritance(spliced) == want, (
        f"subset {subset}: the splice lost cross-file inheritance — missing "
        f"{sorted(want - _inheritance(spliced))}"
    )

Activity · 26 steps
lines 76–76root = tmp_path / "repo"lines 77–77(root / "include").mkdir(parents=True)lines 78–82(root / "include" / "base.h").write_text( "/** @brief A base. */\nstruct Base {\n /** @brief Area. */\n virtual int area() const;\n" " virtual ~Base() {}\n};\n", encoding="utf-8", )lines 83–87(root / "include" / "derived.h").write_text( '#include "base.h"\n/** @brief A derived. */\nstruct Derived : Base {\n' " /** @brief Area. */\n int area() const override;\n};\n", encoding="utf-8", )lines 88–88doxyfile = tmp_path / "Doxyfile"lines 89–93doxyfile.write_text( f"PROJECT_NAME = inh\nINPUT = {root}\nGENERATE_SQLITE3 = YES\nEXTRACT_ALL = YES\n" "REFERENCED_BY_RELATION = YES\nREFERENCES_RELATION = YES\n", encoding="utf-8", )lines 94–94master = tmp_path / "master-kept.db"lines 95–95shutil.copy2(_run(doxyfile, tmp_path / "master", root), master)lines 98–98base = root / "include" / "base.h"lines 99–99base.write_text(base.read_text().replace("A base.", "A base, reworded."), encoding="utf-8")lines 100–100changed = {"include/base.h"}lines 102–102truth = tmp_path / "truth-kept.db"lines 103–103shutil.copy2(_run(doxyfile, tmp_path / "truth", root), truth)lines 104–104want = _inheritance(truth)lines 105–107assert ("compoundref", "Base>Derived") in want, ( f"vacuous: the rebuild has no inheritance {want}" )lines 108–108assert ("reimplements", "Derived::area>Base::area") in want, f"vacuous: no override {want}"lines 110–110subset = sorted(xref_closure(master, changed, root))lines 111–111subset_db = _run(doxyfile, tmp_path / "subset", root, subset=subset)lines 112–112extra = include_expansion(subset_db, master, changed, set(subset), root)lines 113–113◇ if extralines 114–114subset = sorted(set(subset) | extra)lines 115–115subset_db = _run(doxyfile, tmp_path / "subset2", root, subset=subset)lines 116–116spliced = tmp_path / "spliced.db"lines 117–117report = splice_doxygen(master, subset_db, changed, spliced, root)lines 119–119assert not report.skipped, report.skippedlines 120–123assert _inheritance(spliced) == want, ( f"subset {subset}: the splice lost cross-file inheritance — missing " f"{sorted(want - _inheritance(spliced))}" )