mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-14 16:09:26 +00:00
Add regression test for dangling edge pruning consistency
group_skipped feeds the dangling reference pruning pass and the write loop must agree with it on whether a recovered group is written or skipped. This proves an edge between two nodes inside the same recovered group survives instead of being pruned as referencing a supposedly skipped id. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
This commit is contained in:
1 parent
12999a80f6
commit
8a23b305fe
1 file changed
+25
@@ -30,6 +30,31 @@ def test_malformed_but_basename_unique_path_recovers(tmp_path):
|
||||
assert {n["id"] for n in cached["nodes"]} == {"n1"}
|
||||
|
||||
|
||||
def test_recovered_group_edges_are_not_pruned_as_dangling(tmp_path):
|
||||
# group_skipped (used by the dangling-reference pruning pass) and the
|
||||
# write loop must agree a recovered group is WRITTEN, not skipped --
|
||||
# otherwise an edge between two nodes in that same recovered group would
|
||||
# be wrongly pruned as referencing a "skipped" id.
|
||||
real = tmp_path / "sub" / "weird_named_file.py"
|
||||
real.parent.mkdir(parents=True)
|
||||
real.write_text("def f(): pass\ndef g(): pass\n")
|
||||
|
||||
nodes = [
|
||||
{"id": "n1", "label": "f", "source_file": "lost_dir/weird_named_file.py"},
|
||||
{"id": "n2", "label": "g", "source_file": "lost_dir/weird_named_file.py"},
|
||||
]
|
||||
edges = [
|
||||
{"source": "n1", "target": "n2", "relation": "calls",
|
||||
"source_file": "lost_dir/weird_named_file.py"},
|
||||
]
|
||||
saved = save_semantic_cache(nodes, edges, root=tmp_path, allowed_source_files=[real])
|
||||
assert saved == 1
|
||||
|
||||
cached = load_cached(real, root=tmp_path, kind="semantic")
|
||||
assert cached is not None
|
||||
assert len(cached["edges"]) == 1
|
||||
|
||||
|
||||
def test_ambiguous_basename_stays_skipped(tmp_path):
|
||||
a = tmp_path / "pkg_a" / "shared.py"
|
||||
b = tmp_path / "pkg_b" / "shared.py"
|
||||
|
||||
Reference in new issue
Block a user