test_macro_refs_caller_file.py¶
tests/test_macro_refs_caller_file.py
A recovered macro reference is credited to the function in the file it was read from.
test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name
None test_macro_refs_caller_file.test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name(Path db, Path tmp_path, pytest.MonkeyPatch monkeypatch)
Unique names fall back; shared names do not.
tests/test_macro_refs_caller_file.py:64
Checks
assert got == [(40, 1)]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name → import_ast_macro_refs |
| REQ-DDB-PIPE-011 | inferred | test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name → import_ast_macro_refs → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name → import_ast_macro_refs → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language |
Source · 22 lines
def test_a_body_with_only_a_prototype_elsewhere_resolves_by_its_unique_name(
db: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""A function whose definition row is missing (the parser dropped it, or only a header
prototype carries the name) keeps its edge when no other function shares the name; `help`,
which is shared, does not fall back.
@brief Unique names fall back; shared names do not. @version 1
"""
conn = sqlite3.connect(db)
conn.execute("INSERT INTO memberdef VALUES (40, 'step', 'function', 5, NULL)")
conn.commit()
conn.close()
payloads = [(6, [("step", "LOG", 9), ("help", "LOG", 12)])]
monkeypatch.setattr(macro_refs, "run_harvest", lambda *a, **k: payloads)
macro_refs.import_ast_macro_refs(db, tmp_path)
conn = sqlite3.connect(db)
got = sorted(conn.execute("SELECT src_rowid, dst_rowid FROM xrefs"))
conn.close()
assert got == [(40, 1)]1 more lines, not shown
Activity · 11 steps
test_each_copy_of_a_function_keeps_its_own_macro_reference
None test_macro_refs_caller_file.test_each_copy_of_a_function_keeps_its_own_macro_reference(Path db, Path tmp_path, pytest.MonkeyPatch monkeypatch)
Both C copies get the edge and the shell function gets none.
tests/test_macro_refs_caller_file.py:46
Checks
assert got == [(10, 1, "ast"), (20, 1, "ast")]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_each_copy_of_a_function_keeps_its_own_macro_reference → import_ast_macro_refs |
| REQ-DDB-PIPE-011 | inferred | test_each_copy_of_a_function_keeps_its_own_macro_reference → import_ast_macro_refs → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_each_copy_of_a_function_keeps_its_own_macro_reference → import_ast_macro_refs → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language |
Source · 18 lines
def test_each_copy_of_a_function_keeps_its_own_macro_reference(
db: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Files 1 and 2 use the macro inside `help`; file 3 (the shell script, last row) does not.
@brief Both C copies get the edge and the shell function gets none. @version 1
"""
payloads = [(1, [("help", "LOG", 4)]), (2, [("help", "LOG", 4)]), (3, [])]
monkeypatch.setattr(macro_refs, "run_harvest", lambda *a, **k: payloads)
macro_refs.import_ast_macro_refs(db, tmp_path)
conn = sqlite3.connect(db)
got = sorted(conn.execute("SELECT src_rowid, dst_rowid, context FROM xrefs"))
conn.close()
assert got == [(10, 1, "ast"), (20, 1, "ast")]