test_extra_seeds_rescue_a_self_loop_false_orphan

Tests › tests/test_python_ast.py

passed Passed in the packaged run.

What this test is for

Why it exists

The exact shape measured on `a Python codebase`: doxygen attributes a `__main__` guard's call to the guarded function ITSELF, so the function has a non-fuzzy incoming edge (excluding it from the zero-incoming source) and its only caller is itself. Without a structural seed it is a FALSE orphan; with one it is live. `dead_helper` must stay orphan either way, proving the seed does not simply mark everything live.

Given

  1. db = tmp_path / "clew.db"
  2. conn = sqlite3.connect(str(db))
5 more
  1. conn.executescript( """ CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER ); CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT); """, )
  2. conn.executemany( "INSERT INTO memberdef (rowid, kind, name, file_id, bodyfile_id, bodystart, " "bodyend) VALUES (?, 'function', ?, 1, 1, ?, ?)", [(1, "guarded", 1, 2), (2, "reached", 3, 4), (3, "dead_helper", 5, 6), (4, "dead2", 7, 8)], )
  3. conn.executemany( "INSERT INTO call_edges VALUES (?, ?, 'ast', 'resolved')", # guarded -> guarded (the doxygen self-loop), guarded -> reached, # and a dead mutually-recursive pair so neither is zero-incoming. [(1, 1), (1, 2), (3, 4), (4, 3)], )
  4. conn.commit()
  5. conn.close()
→

When

  1. mark_reachability(db, entry_patterns=["nothing_matches"])
  2. conn = sqlite3.connect(str(db))
  3. before = dict(conn.execute("SELECT memberdef_rowid, status FROM symbol_liveness"))
5 more
  1. conn.close()
  2. mark_reachability(db, entry_patterns=["nothing_matches"], extra_seeds={1})
  3. conn = sqlite3.connect(str(db))
  4. after = dict(conn.execute("SELECT memberdef_rowid, status FROM symbol_liveness"))
  5. conn.close()
→

Then

  1. ✓ before[1] equals "orphan"
  2. ✓ after[1] equals "live"
  3. ✓ after[2] equals "live"
  4. ✓ after[3] equals "orphan"
  5. ✓ after[4] equals "orphan"

tests/test_python_ast.py:688 · its file's page

What it checks (5)

  1. assert before[1] == "orphan", "expected the self-loop entry to be a false orphan" not attributed
  2. assert after[1] == "live", "structural seed did not rescue the entry point" not attributed
  3. assert after[2] == "live", "the entry's callee should now be reachable" not attributed
  4. assert after[3] == "orphan", "a genuinely dead function must stay orphan" not attributed
  5. assert after[4] == "orphan" not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_extra_seeds_rescue_a_self_loop_false_orphan→mark_reachability

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_extra_seeds_rescue_a_self_loop_false_orphan · 5 checksmark_reachabilityREQ-DDB-PIPE-004 · measured
Also reaches 2 requirements

Its run touches their code; that is reach, not proof.