test_wiki_frameworks.py

tests/test_wiki_frameworks.py

Standard test structures (owner 2026-11-15: "allow for catch2, pytest, ceedling, gcovr, standard test structures").

test_a_catch2_scenario_is_found_under_the_name_catch2_reports

test_a_catch2_scenario_is_found_under_the_name_catch2_reports()

tests/test_wiki_frameworks.py:202

Checks

  • assert test == ("loads a file", ("loads a file", "Scenario: loads a file"))

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-017measuredtest_a_catch2_scenario_is_found_under_the_name_catch2_reports → recognise_test
Source · 11 lines
def test_a_catch2_scenario_is_found_under_the_name_catch2_reports() -> None:
    """FOUND ON SASSAFRAS-CLASS (round 4): Catch2 reports a SCENARIO as "Scenario: <name>" (its
    JUnit and ctest's discovered names alike), while the index holds the macro's string. The
    scenario is filed under both, so its result is found; its display name stays the string.

    @brief SCENARIO lookup names include Catch2's "Scenario: " form.
    """
    from clew.wiki.frameworks import recognise_test

    test = recognise_test("SCENARIO", '("loads a file", "[load]")', "tests/test_x.cpp")
    assert test == ("loads a file", ("loads a file", "Scenario: loads a file"))
Activity · 3 steps
lines 209–209from clew.wiki.frameworks import recognise_testlines 211–211test = recognise_test("SCENARIO", '("loads a file", "[load]")', "tests/test_x.cpp")lines 212–212assert test == ("loads a file", ("loads a file", "Scenario: loads a file"))

test_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name

test_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name(tmp_path: Path)

tests/test_wiki_frameworks.py:107

Checks

  • assert row.tests == (("a store loads", "passed"),) and row.inferred_tests == ("a store loads",)
  • assert row.tier == "PASS"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name → requirement_evidence → connect
REQ-DDB-QUERY-003measuredtest_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name → requirement_evidence → _implementer_spans → table_exists
REQ-DDB-WIKI-002measuredtest_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name → requirement_evidence
REQ-DDB-WIKI-010measured
REQ-DDB-WIKI-016measured
REQ-DDB-WIKI-017measured
REQ-DDB-WIKI-054inferredtest_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name → requirement_evidence → _tier → all
Source · 37 lines
def test_a_catch2_scenario_reaching_an_implementer_is_linked_by_its_name(tmp_path: Path) -> None:
    """@brief Inference walks back to a SCENARIO row and files it under its Catch2 name."""
    db = tmp_path / "c.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, kind TEXT, name TEXT, file_id INTEGER,
            bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER, definition TEXT,
            argsstring TEXT, briefdescription TEXT, detaileddescription TEXT);
        CREATE TABLE requirements (id TEXT PRIMARY KEY, block TEXT, title TEXT, acceptance TEXT,
            priority TEXT);
        CREATE TABLE req_edges (memberdef_rowid INTEGER, req_id TEXT);
        CREATE TABLE req_test_edges (test_memberdef_rowid INTEGER, req_id TEXT);
        CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT,
            confidence TEXT, via_macro_rowid INTEGER);
        INSERT INTO path VALUES (1, 'src/store.cpp', 1), (2, 'tests/test_store.cpp', 1);
        INSERT INTO memberdef VALUES
            (1, 'function', 'load', 1, 1, 10, 20, 'void load', '()', '', ''),
            (2, 'function', 'SCENARIO', 2, 2, 5, 9, 'SCENARIO', '("a store loads", "[store]")', '', '');
        INSERT INTO requirements VALUES ('R-1', '', 'load', '', '');
        INSERT INTO req_edges VALUES (1, 'R-1');
        INSERT INTO call_edges VALUES (2, 1, 'ast', 'resolved', NULL);
        """
    )
    conn.commit()
    conn.close()
    report = tmp_path / "catch.xml"
    report.write_text(
        '<Catch2TestRun><TestCase name="a store loads"><OverallResult success="true"/></TestCase>'
        "</Catch2TestRun>"
    )
    inputs = EvidenceInputs(results=(("catch2", "catch.xml"),), evidence_fields=())
    (row,) = requirement_evidence(db, junit=[], inputs=inputs, repo_root=tmp_path)
    assert row.tests == (("a store loads", "passed"),) and row.inferred_tests == ("a store loads",)
    assert row.tier == "PASS"
    json.dumps(row.tests)
Activity · 12 steps
lines 109–109db = tmp_path / "c.db"lines 110–110conn = sqlite3.connect(str(db))lines 111–131conn.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, bodystart INTEGER, bodyend INTEGER, definition TEXT, argsstring TEXT, briefdescription TEXT, detaileddescription TEXT); CREATE TABLE requirements (id TEXT PRIMARY KEY, block TEXT, title TEXT, acceptance TEXT, priority TEXT); CREATE TABLE req_edges (memberdef_rowid INTEGER, req_id TEXT); CREATE TABLE req_test_edges (test_memberdef_rowid INTEGER, req_id TEXT); CREATE TABLE call_edges (caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT, via_macro_rowid INTEGER); INSERT INTO path VALUES (1, 'src/store.cpp', 1), (2, 'tests/test_store.cpp', 1); INSERT INTO memberdef VALUES (1, 'function', 'load', 1, 1, 10, 20, 'void load', '()', '', ''), (2, 'function', 'SCENARIO', 2, 2, 5, 9, 'SCENARIO', '("a store loads", "[store]")', '', ''); INSERT INTO requirements VALUES ('R-1', '', 'load', '', ''); INSERT INTO req_edges VALUES (1, 'R-1'); INSERT INTO call_edges VALUES (2, 1, 'ast', 'resolved', NULL); """ )lines 132–132conn.commit()lines 133–133conn.close()lines 134–134report = tmp_path / "catch.xml"lines 135–138report.write_text( '<Catch2TestRun><TestCase name="a store loads"><OverallResult success="true"/></TestCase>' "</Catch2TestRun>" )lines 139–139inputs = EvidenceInputs(results=(("catch2", "catch.xml"),), evidence_fields=())lines 140–140(row,) = requirement_evidence(db, junit=[], inputs=inputs, repo_root=tmp_path)lines 141–141assert row.tests == (("a store loads", "passed"),) and row.inferred_tests == ("a store loads",)lines 142–142assert row.tier == "PASS"lines 143–143json.dumps(row.tests)

test_a_googletest_notrun_case_is_a_skip

test_a_googletest_notrun_case_is_a_skip(tmp_path: Path)

tests/test_wiki_frameworks.py:91

Show on the map →

Called by none

Calls parse_junit

Checks

  • assert results["Loads"].status == "passed" and results["DISABLED_Flash"].status == "skipped"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-002measuredtest_a_googletest_notrun_case_is_a_skip → parse_junit
REQ-DDB-WIKI-010measuredtest_a_googletest_notrun_case_is_a_skip → parse_junit → fold_cases
REQ-DDB-WIKI-017catalog
Source · 14 lines
def test_a_googletest_notrun_case_is_a_skip(tmp_path: Path) -> None:
    """GoogleTest writes a DISABLED test as `status="notrun"` with no child element; read as passed,
    it would turn an unexecuted test into evidence.

    @brief gtest XML through the JUnit reader.
    """
    report = tmp_path / "gtest.xml"
    report.write_text(
        '<testsuites><testsuite name="Store"><testcase name="Loads" status="run" result="completed"/>'
        '<testcase name="DISABLED_Flash" status="notrun" result="suppressed"/>'
        '<testcase name="Saves" status="run" result="skipped"><skipped/></testcase></testsuite></testsuites>'
    )
    results = parse_junit([report])
    assert results["Loads"].status == "passed" and results["DISABLED_Flash"].status == "skipped"
Activity · 4 steps
lines 97–97report = tmp_path / "gtest.xml"lines 98–102report.write_text( '<testsuites><testsuite name="Store"><testcase name="Loads" status="run" result="completed"/>' '<testcase name="DISABLED_Flash" status="notrun" result="suppressed"/>' '<testcase name="Saves" status="run" result="skipped"><skipped/></testcase></testsuite></testsuites>' )lines 103–103results = parse_junit([report])lines 104–104assert results["Loads"].status == "passed" and results["DISABLED_Flash"].status == "skipped"

test_a_macro_test_gets_its_own_page_under_its_framework_name

test_a_macro_test_gets_its_own_page_under_its_framework_name(tmp_path: Path)

tests/test_wiki_frameworks.py:146

Checks

  • assert [(d.name, d.file, d.start) for d in defs] == [("Loads a file", "tests/test_x.cpp", 3)]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_macro_test_gets_its_own_page_under_its_framework_name → _test_definitions → table_exists
REQ-DDB-WIKI-017measured
REQ-DDB-WIKI-026measuredtest_a_macro_test_gets_its_own_page_under_its_framework_name → _test_definitions
Source · 28 lines
def test_a_macro_test_gets_its_own_page_under_its_framework_name(tmp_path: Path) -> None:
    """FOUND ON ENTROPIC (round 4): 2,009 Catch2 tests and 11 test pages — a SCENARIO is a macro
    row named `SCENARIO` in the index, so test pages looked for a function named after the scenario
    and found none. A test page resolves tests the way the evidence does (`recognise_test`).

    @brief R6: Catch2 / GoogleTest cases get test pages.
    """
    import sqlite3

    from clew.wiki.testpages import _test_definitions

    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 test_scope (path_rowid INTEGER);
            CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT,
                file_id INTEGER, bodyfile_id INTEGER, definition TEXT, argsstring TEXT,
                briefdescription TEXT, bodystart INTEGER, bodyend INTEGER, line INTEGER);
            INSERT INTO path VALUES (1, 'tests/test_x.cpp', 1);
            INSERT INTO test_scope VALUES (1);
            INSERT INTO memberdef VALUES (1, 'function', 'SCENARIO', 1, 1, 'SCENARIO',
                '("Loads a file", "[load]")', '', 3, 9, 3);
            """
        )
        defs = _test_definitions(conn, {"Loads a file"})
    assert [(d.name, d.file, d.start) for d in defs] == [("Loads a file", "tests/test_x.cpp", 3)]
Activity · 7 steps
lines 153–153import sqlite3lines 155–155from clew.wiki.testpages import _test_definitionslines 157–157db = tmp_path / "clew.db"lines 158–158with sqlite3.connect(db) as connlines 159–171conn.executescript( """ CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER); CREATE TABLE test_scope (path_rowid INTEGER); CREATE TABLE memberdef (rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, definition TEXT, argsstring TEXT, briefdescription TEXT, bodystart INTEGER, bodyend INTEGER, line INTEGER); INSERT INTO path VALUES (1, 'tests/test_x.cpp', 1); INSERT INTO test_scope VALUES (1); INSERT INTO memberdef VALUES (1, 'function', 'SCENARIO', 1, 1, 'SCENARIO', '("Loads a file", "[load]")', '', 3, 9, 3); """ )lines 172–172defs = _test_definitions(conn, {"Loads a file"})lines 173–173assert [(d.name, d.file, d.start) for d in defs] == [("Loads a file", "tests/test_x.cpp", 3)]

test_a_test_named_function_outside_test_code_is_not_a_test

test_a_test_named_function_outside_test_code_is_not_a_test()

tests/test_wiki_frameworks.py:215

Checks

  • assert recognise_test("test_pages", "", "clew/wiki/testpages.py") is None
  • assert recognise_test("test_load", "", "tests/test_data.py") == ("test_load", ("test_load",))

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-017measuredtest_a_test_named_function_outside_test_code_is_not_a_test → recognise_test
Source · 12 lines
def test_a_test_named_function_outside_test_code_is_not_a_test() -> None:
    """FOUND ON CLEW'S OWN WIKI (round 4): `test_pages`, `test_link`, `test_id` — production
    functions in clew/wiki/ — were found as "tests" by the call-graph walk, the same defect R9
    fixed for tagged tests. A plain `test*` name is a test only in test code, as the macro forms
    already required.

    @brief recognise_test: plain names need a test path.
    """
    from clew.wiki.frameworks import recognise_test

    assert recognise_test("test_pages", "", "clew/wiki/testpages.py") is None
    assert recognise_test("test_load", "", "tests/test_data.py") == ("test_load", ("test_load",))
Activity · 3 steps
lines 223–223from clew.wiki.frameworks import recognise_testlines 225–225assert recognise_test("test_pages", "", "clew/wiki/testpages.py") is Nonelines 226–226assert recognise_test("test_load", "", "tests/test_data.py") == ("test_load", ("test_load",))

test_catch2_section_cases_fold_into_their_test_case

test_catch2_section_cases_fold_into_their_test_case(tmp_path: Path)

tests/test_wiki_frameworks.py:176

Show on the map →

Called by none

Calls parse_junit

Checks

  • assert set(results) == {"Scenario: X", "Scenario: Y"}
  • assert results["Scenario: X"].status == "failed" and results["Scenario: X"].cases == 2
  • assert "REQUIRE(n == 2 )" in results["Scenario: X"].message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-002measuredtest_catch2_section_cases_fold_into_their_test_case → parse_junit
REQ-DDB-WIKI-010measuredtest_catch2_section_cases_fold_into_their_test_case → parse_junit → fold_cases
REQ-DDB-WIKI-017catalog
Source · 24 lines
def test_catch2_section_cases_fold_into_their_test_case(tmp_path: Path) -> None:
    """FOUND ON SASSAFRAS-CLASS (round 4): Catch2's own JUnit reporter writes one testcase per
    SECTION PATH ("Scenario: X/Given: a/When: b"), under classname `<binary>.global`; the index
    knows the test case ("Scenario: X"), so 230 of 267 tested requirements read NOT_RUN. Section
    cases fold into their test case, worst status first — and a FAILURE keeps its message, which
    a test page shows in red (only skip messages were kept).

    @brief Catch2 section folding; failure messages kept.
    """
    from clew.wiki.evidence import parse_junit

    report = tmp_path / "catch2.xml"
    report.write_text(
        '<testsuites><testsuite name="t">'
        '<testcase classname="t.global" name="Scenario: X/Given: a" status="run"/>'
        '<testcase classname="t.global" name="Scenario: X/Given: a/When: b" status="run">'
        '<failure message="REQUIRE( n == 2 )">expanded: 1 == 2</failure></testcase>'
        '<testcase classname="t.global" name="Scenario: Y" status="run"/>'
        "</testsuite></testsuites>"
    )
    results = parse_junit([report])
    assert set(results) == {"Scenario: X", "Scenario: Y"}
    assert results["Scenario: X"].status == "failed" and results["Scenario: X"].cases == 2
    assert "REQUIRE( n == 2 )" in results["Scenario: X"].message
Activity · 7 steps
lines 185–185from clew.wiki.evidence import parse_junitlines 187–187report = tmp_path / "catch2.xml"lines 188–195report.write_text( '<testsuites><testsuite name="t">' '<testcase classname="t.global" name="Scenario: X/Given: a" status="run"/>' '<testcase classname="t.global" name="Scenario: X/Given: a/When: b" status="run">' '<failure message="REQUIRE( n == 2 )">expanded: 1 == 2</failure></testcase>' '<testcase classname="t.global" name="Scenario: Y" status="run"/>' "</testsuite></testsuites>" )lines 196–196results = parse_junit([report])lines 197–197assert set(results) == {"Scenario: X", "Scenario: Y"}lines 198–198assert results["Scenario: X"].status == "failed" and results["Scenario: X"].cases == 2lines 199–199assert "REQUIRE( n == 2 )" in results["Scenario: X"].message

test_ceedling_and_unity_results_are_read

test_ceedling_and_unity_results_are_read(tmp_path: Path)

tests/test_wiki_frameworks.py:72

Checks

  • assert {k: v.status for k, v in parse_results("ceedling", ceedling).items()} == expected
  • assert {k: v.status for k, v in parse_results("unity", unity).items()} == expected

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-010measuredtest_ceedling_and_unity_results_are_read → parse_results
REQ-DDB-WIKI-017catalog
Source · 17 lines
def test_ceedling_and_unity_results_are_read(tmp_path: Path) -> None:
    """@brief Ceedling's XML report and Unity's text output."""
    ceedling = tmp_path / "report.xml"
    ceedling.write_text(
        "<TestRun><FailedTests><Test id='1'><Name>test/test_store.c::test_saves</Name></Test>"
        "</FailedTests><SuccessfulTests><Test id='2'><Name>test/test_store.c::test_loads</Name>"
        "</Test></SuccessfulTests><IgnoredTests><Test id='3'><Name>test/test_store.c::test_hw</Name>"
        "</Test></IgnoredTests></TestRun>"
    )
    unity = tmp_path / "unity.txt"
    unity.write_text(
        "test/test_store.c:10:test_loads:PASS\ntest/test_store.c:20:test_saves:FAIL: Expected 1\n"
        "test/test_store.c:30:test_hw:IGNORE\n-----------------------\n3 Tests 1 Failures 1 Ignored\n"
    )
    expected = {"test_loads": "passed", "test_saves": "failed", "test_hw": "skipped"}
    assert {k: v.status for k, v in parse_results("ceedling", ceedling).items()} == expected
    assert {k: v.status for k, v in parse_results("unity", unity).items()} == expected
Activity · 7 steps
lines 74–74ceedling = tmp_path / "report.xml"lines 75–80ceedling.write_text( "<TestRun><FailedTests><Test id='1'><Name>test/test_store.c::test_saves</Name></Test>" "</FailedTests><SuccessfulTests><Test id='2'><Name>test/test_store.c::test_loads</Name>" "</Test></SuccessfulTests><IgnoredTests><Test id='3'><Name>test/test_store.c::test_hw</Name>" "</Test></IgnoredTests></TestRun>" )lines 81–81unity = tmp_path / "unity.txt"lines 82–85unity.write_text( "test/test_store.c:10:test_loads:PASS\ntest/test_store.c:20:test_saves:FAIL: Expected 1\n" "test/test_store.c:30:test_hw:IGNORE\n-----------------------\n3 Tests 1 Failures 1 Ignored\n" )lines 86–86expected = {"test_loads": "passed", "test_saves": "failed", "test_hw": "skipped"}lines 87–87assert {k: v.status for k, v in parse_results("ceedling", ceedling).items()} == expectedlines 88–88assert {k: v.status for k, v in parse_results("unity", unity).items()} == expected

test_each_framework_shape_is_recognised

test_each_framework_shape_is_recognised(name, args, path, expected)

tests/test_wiki_frameworks.py:64

Checks

  • assert recognise_test(name, args, path) == expected

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-017measuredtest_each_framework_shape_is_recognised → recognise_test
Source · 6 lines
def test_each_framework_shape_is_recognised(name, args, path, expected) -> None:
    """A MACRO ROW OUTSIDE TEST CODE is not a test (`SCENARIO` may be anyone's function).

    @brief Framework recognition: display name and the names results are filed under.
    """
    assert recognise_test(name, args, path) == expected
Activity · 1 steps
lines 69–69assert recognise_test(name, args, path) == expected