test_wiki_entrypoints_body.py

tests/test_wiki_entrypoints_body.py

An entry point is named by the file that DEFINES it (round 4).

test_a_main_declared_in_a_header_is_found_at_its_definition

None test_wiki_entrypoints_body.test_a_main_declared_in_a_header_is_found_at_its_definition(Path tmp_path)

main's spec names main.c (its body), not main.h (its declaration).

tests/test_wiki_entrypoints_body.py:21

Checks

  • assert [(s.entry, s.file) for s in specs] == [("main", "src/main.c")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → _mains → _declared_entry_patterns → load_declaration
REQ-DDB-GUARD-012inferredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → _mains → _declared_entry_patterns → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-PIPE-004measuredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → _scripts → console_scripts
REQ-DDB-QUERY-001measuredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → connect
REQ-DDB-QUERY-003measuredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → _calls_something → table_exists
REQ-DDB-WIKI-018measuredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows
REQ-DDB-WIKI-054inferredtest_a_main_declared_in_a_header_is_found_at_its_definition → entry_point_flows → _mains → _declared_entry_patterns → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all
Source · 18 lines
def test_a_main_declared_in_a_header_is_found_at_its_definition(tmp_path: Path) -> None:
    """@brief main's spec names main.c (its body), not main.h (its declaration)."""
    db = tmp_path / "clew.db"
    with sqlite3.connect(db) as conn:
        conn.executescript(
            """
            CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER);
            CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT,
                file_id INTEGER, bodyfile_id INTEGER);
            CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT,
                confidence TEXT);
            INSERT INTO path VALUES (1, 'src/main.h', 1), (2, 'src/main.c', 1);
            INSERT INTO memberdef VALUES (1, 'function', 'main', 1, 2), (2, 'function', 'run', 2, 2);
            INSERT INTO call_edges VALUES (1, 2, 'ast', 'resolved');
            """
        )
    specs = entry_point_flows(db, tmp_path, 2)
    assert [(s.entry, s.file) for s in specs] == [("main", "src/main.c")]

1 more lines, not shown

Activity · 5 steps
lines 23–23db = tmp_path / "clew.db"lines 24–24with sqlite3.connect(db) as connlines 25–36conn.executescript( """ CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER); CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER); CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT); INSERT INTO path VALUES (1, 'src/main.h', 1), (2, 'src/main.c', 1); INSERT INTO memberdef VALUES (1, 'function', 'main', 1, 2), (2, 'function', 'run', 2, 2); INSERT INTO call_edges VALUES (1, 2, 'ast', 'resolved'); """ )lines 37–37specs = entry_point_flows(db, tmp_path, 2)lines 38–38assert [(s.entry, s.file) for s in specs] == [("main", "src/main.c")]