test_repair_attribute.py¶
tests/test_repair_attribute.py
Tests for repair_attribute_named_functions — fix doxygen's __attribute__ mislabel.
test_repair_merges_body_into_declaration
test_repair_attribute.test_repair_merges_body_into_declaration(tmp_path)
With a decl row present, the body transfers to it and the attribute row is deleted.
tests/test_repair_attribute.py:56
Checks
assert n == 1assert attr == 0assert rows == [(20, "real_fn", 2, 6)] # single row, decl now owns the body
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_repair_merges_body_into_declaration → repair_attribute_named_functions |
| REQ-DDB-PIPE-011 | measured | test_repair_merges_body_into_declaration → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_repair_merges_body_into_declaration → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language |
Source · 16 lines
def test_repair_merges_body_into_declaration(tmp_path):
(tmp_path / "mod.c").write_text(_SRC)
db = tmp_path / "d.db"
_make_db(db, with_decl=True)
n = repair_attribute_named_functions(db, tmp_path)
assert n == 1
conn = sqlite3.connect(str(db))
rows = conn.execute(
"SELECT rowid, name, bodystart, bodyend FROM memberdef WHERE name='real_fn'"
).fetchall()
attr = conn.execute("SELECT COUNT(*) FROM memberdef WHERE name='__attribute__'").fetchone()[0]
conn.close()
assert attr == 0
assert rows == [(20, "real_fn", 2, 6)] # single row, decl now owns the body
Activity · 11 steps
test_repair_noop_without_attribute_rows
test_repair_attribute.test_repair_noop_without_attribute_rows(tmp_path)
No attribute rows -> no-op.
tests/test_repair_attribute.py:90
Checks
assert repair_attribute_named_functions(db, tmp_path) == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_repair_noop_without_attribute_rows → repair_attribute_named_functions |
| REQ-DDB-PIPE-011 | inferred | test_repair_noop_without_attribute_rows → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_repair_noop_without_attribute_rows → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language |
Source · 14 lines
def test_repair_noop_without_attribute_rows(tmp_path):
db = tmp_path / "d.db"
conn = sqlite3.connect(str(db))
conn.executescript(
"CREATE TABLE path(rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER);"
"CREATE TABLE memberdef(rowid INTEGER PRIMARY KEY, name TEXT, kind TEXT,"
" file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER);"
"INSERT INTO path(rowid,name,type) VALUES(1,'mod.c',1);"
"INSERT INTO memberdef(rowid,name,kind,file_id,bodyfile_id,bodystart,bodyend)"
" VALUES(1,'ok_fn','function',1,1,2,4);"
)
conn.commit()
conn.close()
assert repair_attribute_named_functions(db, tmp_path) == 01 more lines, not shown
Activity · 6 steps
test_repair_renames_when_no_declaration
test_repair_attribute.test_repair_renames_when_no_declaration(tmp_path)
With no decl row, the attribute row is renamed in place.
tests/test_repair_attribute.py:74
Checks
assert n == 1assert row == (10, "real_fn", 2) # same row, renamed
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_repair_renames_when_no_declaration → repair_attribute_named_functions |
| REQ-DDB-PIPE-011 | measured | test_repair_renames_when_no_declaration → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | inferred | test_repair_renames_when_no_declaration → repair_attribute_named_functions → _real_function_name_at → _ast_parse_one_file → _ts_language_for → _grammar_available → has_language |
Source · 14 lines
def test_repair_renames_when_no_declaration(tmp_path):
(tmp_path / "mod.c").write_text(_SRC)
db = tmp_path / "d.db"
_make_db(db, with_decl=False)
n = repair_attribute_named_functions(db, tmp_path)
assert n == 1
conn = sqlite3.connect(str(db))
row = conn.execute(
"SELECT rowid, name, bodystart FROM memberdef WHERE name='real_fn'"
).fetchone()
conn.close()
assert row == (10, "real_fn", 2) # same row, renamed