test_preprocessor.py

tests/test_preprocessor.py

The declared PREPROCESSOR CONFIGURATION an index represents (gh#17).

test_a_declared_config_header_outside_the_repository_is_refused

None test_preprocessor.test_a_declared_config_header_outside_the_repository_is_refused(Path tmp_path)

A declared config_header outside the repository is refused.

tests/test_preprocessor.py:865

Checks

  • assert config.macros == (), (f"{declared!r} escapes the repository; got macros {config.macros}" )
  • assert config.config_header is None, (f"a refused header must not be recorded as honoured; got {config.config_header}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_a_declared_config_header_outside_the_repository_is_refused → resolve_preprocessor
REQ-DDB-PIPE-014measuredtest_a_declared_config_header_outside_the_repository_is_refused → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 28 lines
def test_a_declared_config_header_outside_the_repository_is_refused(tmp_path: Path) -> None:
    """H4's second site. `preprocessor.config_header` is repo-relative by contract and was
    resolved without containment, so a declared — or MCP-STATED — `/etc/hostname` or
    `../outside.h` was read and its `#define`s became this index's macro set. The macro
    values then reach the Doxyfile's PREDEFINED, which is how a read turns into content an
    agent is served as the repository's own configuration.

    Refused as a missing path is: no macros, no recorded header, one warning.

    @brief An escaping config_header contributes no macros.
    @return None.
    @version 1
    """
    outside = tmp_path / "outside.h"
    outside.write_text("#define SENTINEL_LEAKED 1\n", encoding="utf-8")

    root = tmp_path / "repo"
    root.mkdir()

    for declared in (str(outside), "../outside.h"):
        config = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"config_header": declared}})

        assert config.macros == (), (
            f"{declared!r} escapes the repository; got macros {config.macros}"
        )
        assert config.config_header is None, (
            f"a refused header must not be recorded as honoured; got {config.config_header}"
        )

1 more lines, not shown

Activity · 8 steps
lines 878–878outside = tmp_path / "outside.h"lines 879–879outside.write_text("#define SENTINEL_LEAKED 1\n", encoding="utf-8")lines 881–881root = tmp_path / "repo"lines 882–882root.mkdir()lines 884–884◇ for declared in (str(outside), "../outside.h")lines 885–885config = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"config_header": declared}})lines 887–889assert config.macros == (), ( f"{declared!r} escapes the repository; got macros {config.macros}" )lines 890–892assert config.config_header is None, ( f"a refused header must not be recorded as honoured; got {config.config_header}" )

test_a_declared_config_header_supplies_its_macros

None test_preprocessor.test_a_declared_config_header_supplies_its_macros(Path tmp_path)

A declared config header supplies its macros, including a valued one.

tests/test_preprocessor.py:284

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo, _meta

Checks

  • assert "feature_entry" in functions, "the header's bare #define was not supplied"
  • assert "wide_entry" in functions, "the header's macro VALUE was not supplied"
  • assert meta["source"] == SOURCE_CONFIG_HEADER
  • assert meta["config_header"] == "include/fixture_config.h"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-012measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-013measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 21 lines
def test_a_declared_config_header_supplies_its_macros(tmp_path: Path) -> None:
    """gh#17 part 2, end to end. `wide_entry` is the load-bearing assertion: it sits
    behind `FIXTURE_WIDTH == 16`, so it indexes only if the harvest carried the macro's
    VALUE and not merely its name — which is the difference between reading a
    configuration and noticing one exists.
    """
    root = _fixture_repo(
        tmp_path,
        declaration="preprocessor:\n  config_header: include/fixture_config.h\n",
    )
    db = _build(root, tmp_path / "out.db")
    functions = _doxygen_functions(db)

    assert "feature_entry" in functions, "the header's bare #define was not supplied"
    assert "wide_entry" in functions, "the header's macro VALUE was not supplied"

    meta = _meta(db, "preprocessor")
    assert meta["source"] == SOURCE_CONFIG_HEADER
    assert meta["config_header"] == "include/fixture_config.h"

Activity · 8 steps
lines 290–293root = _fixture_repo( tmp_path, declaration="preprocessor:\n config_header: include/fixture_config.h\n", )lines 294–294db = _build(root, tmp_path / "out.db")lines 295–295functions = _doxygen_functions(db)lines 297–297assert "feature_entry" in functions, "the header's bare #define was not supplied"lines 298–298assert "wide_entry" in functions, "the header's macro VALUE was not supplied"lines 300–300meta = _meta(db, "preprocessor")lines 301–301assert meta["source"] == SOURCE_CONFIG_HEADERlines 302–302assert meta["config_header"] == "include/fixture_config.h"

test_a_declared_macro_wins_over_the_header

None test_preprocessor.test_a_declared_macro_wins_over_the_header(Path tmp_path)

A declared macro beats a harvested one of the same name.

tests/test_preprocessor.py:607

Checks

  • assert '"WIDTH=16"' in config.macros
  • assert '"WIDTH=8"' not in config.macros, "the header overrode a hand-written declaration"
  • assert '"ONLY_IN_HEADER=1"' in config.macros, "the header's other macros were dropped"
  • assert config.source == SOURCE_BOTH

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_a_declared_macro_wins_over_the_header → resolve_preprocessor
REQ-DDB-PIPE-014measuredtest_a_declared_macro_wins_over_the_header → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 18 lines
def test_a_declared_macro_wins_over_the_header(tmp_path: Path) -> None:
    """Doxygen's behaviour on a duplicated PREDEFINED name is not something to rely on,
    so the collision is resolved where the rule can be stated: the owner typed one of
    these by hand and the other was read out of a file.
    """
    root = tmp_path / "repo"
    root.mkdir()
    (root / "cfg.h").write_text("#define WIDTH 8\n#define ONLY_IN_HEADER 1\n", encoding="utf-8")
    config = resolve_preprocessor(
        root,
        {SECTION_PREPROCESSOR: {"predefined": ["WIDTH=16"], "config_header": "cfg.h"}},
    )
    assert '"WIDTH=16"' in config.macros
    assert '"WIDTH=8"' not in config.macros, "the header overrode a hand-written declaration"
    assert '"ONLY_IN_HEADER=1"' in config.macros, "the header's other macros were dropped"
    assert config.source == SOURCE_BOTH

Activity · 8 steps
lines 612–612root = tmp_path / "repo"lines 613–613root.mkdir()lines 614–614(root / "cfg.h").write_text("#define WIDTH 8\n#define ONLY_IN_HEADER 1\n", encoding="utf-8")lines 615–618config = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"predefined": ["WIDTH=16"], "config_header": "cfg.h"}}, )lines 619–619assert '"WIDTH=16"' in config.macroslines 620–620assert '"WIDTH=8"' not in config.macros, "the header overrode a hand-written declaration"lines 621–621assert '"ONLY_IN_HEADER=1"' in config.macros, "the header's other macros were dropped"lines 622–622assert config.source == SOURCE_BOTH

test_a_declared_predefined_list_reaches_doxygen

None test_preprocessor.test_a_declared_predefined_list_reaches_doxygen(Path tmp_path)

A declared predefined: list reaches doxygen and indexes guarded code.

tests/test_preprocessor.py:224

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo

Checks

  • assert "always_present" in with_macro, "the control function must index either way"
  • assert "always_present" in without, "the control function must index either way"
  • assert "feature_entry" in with_macro, "the declared macro did not reach doxygen"
  • assert "feature_entry" not in without, ("the guarded function indexed with NO macro declared — this fixture cannot " "prove anything about PREDEFINED" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-012measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-013measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 28 lines
def test_a_declared_predefined_list_reaches_doxygen(tmp_path: Path) -> None:
    """THE test for gh#17 part 1, and it fails before the change with
    `feature_entry` absent — nothing in the pipeline set `PREDEFINED`, so every
    occurrence of the word was prose in a warning.

    Asserted in BOTH directions against the same fixture, because only the negative
    half shows the macro is what did it: an undeclared build must NOT hold
    `feature_entry`. Without that, a doxygen version indexing guarded branches
    regardless would pass the positive half and the test would be measuring nothing.
    """
    declared = _fixture_repo(
        tmp_path / "yes",
        declaration="preprocessor:\n  predefined:\n    - FIXTURE_FEATURE_C\n",
    )
    bare = _fixture_repo(tmp_path / "no")

    with_macro = _doxygen_functions(_build(declared, tmp_path / "yes.db"))
    without = _doxygen_functions(_build(bare, tmp_path / "no.db"))

    assert "always_present" in with_macro, "the control function must index either way"
    assert "always_present" in without, "the control function must index either way"
    assert "feature_entry" in with_macro, "the declared macro did not reach doxygen"
    assert "feature_entry" not in without, (
        "the guarded function indexed with NO macro declared — this fixture cannot "
        "prove anything about PREDEFINED"
    )

Activity · 8 steps
lines 234–237declared = _fixture_repo( tmp_path / "yes", declaration="preprocessor:\n predefined:\n - FIXTURE_FEATURE_C\n", )lines 238–238bare = _fixture_repo(tmp_path / "no")lines 240–240with_macro = _doxygen_functions(_build(declared, tmp_path / "yes.db"))lines 241–241without = _doxygen_functions(_build(bare, tmp_path / "no.db"))lines 243–243assert "always_present" in with_macro, "the control function must index either way"lines 244–244assert "always_present" in without, "the control function must index either way"lines 245–245assert "feature_entry" in with_macro, "the declared macro did not reach doxygen"lines 246–249assert "feature_entry" not in without, ( "the guarded function indexed with NO macro declared — this fixture cannot " "prove anything about PREDEFINED" )

test_a_missing_named_header_is_still_recorded

None test_preprocessor.test_a_missing_named_header_is_still_recorded(Path tmp_path)

A named-but-missing config header records the declaration and warns.

tests/test_preprocessor.py:583

Checks

  • assert config.declared
  • assert config.source == SOURCE_CONFIG_HEADER
  • assert config.as_meta()["macro_count"] == "0", "a measured zero must be persisted"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_a_missing_named_header_is_still_recorded → resolve_preprocessor
REQ-DDB-PIPE-014measuredtest_a_missing_named_header_is_still_recorded → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 20 lines
def test_a_missing_named_header_is_still_recorded(tmp_path: Path) -> None:
    """The misspelled-path case, and the reason `as_meta` records a macro count of ZERO
    rather than dropping it. A declaration that produced nothing is a finding; recorded
    as absent it would be indistinguishable from a repo that declared nothing at all.
    """
    root = tmp_path / "repo"
    root.mkdir()
    config = resolve_preprocessor(
        root, {SECTION_PREPROCESSOR: {"config_header": "include/typo_config.h"}}
    )
    assert config.declared
    assert config.source == SOURCE_CONFIG_HEADER
    assert config.as_meta()["macro_count"] == "0", "a measured zero must be persisted"


# --------------------------------------------------------------------------- #
# Resolution rules and provenance.
# --------------------------------------------------------------------------- #

Activity · 6 steps
lines 588–588root = tmp_path / "repo"lines 589–589root.mkdir()lines 590–592config = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"config_header": "include/typo_config.h"}} )lines 593–593assert config.declaredlines 594–594assert config.source == SOURCE_CONFIG_HEADERlines 595–595assert config.as_meta()["macro_count"] == "0", "a measured zero must be persisted"

test_a_misspelled_section_is_refused

None test_preprocessor.test_a_misspelled_section_is_refused(Path tmp_path)

A misspelled section name is refused, not silently ignored.

tests/test_preprocessor.py:675

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_misspelled_section_is_refused → load_declaration
REQ-DDB-CONFIG-004catalog
REQ-DDB-GUARD-012inferredtest_a_misspelled_section_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-PIPE-014catalog
REQ-DDB-WIKI-054inferredtest_a_misspelled_section_is_refused → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all
Source · 15 lines
def test_a_misspelled_section_is_refused(tmp_path: Path) -> None:
    """The allow-list's whole purpose, checked for this section specifically.
    `preprocessors:` parses to a perfectly valid mapping that nothing reads, so the build
    would run with NO macros while the log reported the declaration was honoured — and
    here that means silently indexing a different variant than the owner declared.
    """
    from clew.vocabulary import DeclarationError

    root = tmp_path / "repo"
    root.mkdir()
    (root / ".clew.yaml").write_text("preprocessors:\n  predefined:\n    - A\n", encoding="utf-8")
    with pytest.raises(DeclarationError, match="preprocessors"):
        load_declaration(root)

Activity · 6 steps
lines 681–681from clew.vocabulary import DeclarationErrorlines 683–683root = tmp_path / "repo"lines 684–684root.mkdir()lines 685–685(root / ".clew.yaml").write_text("preprocessors:\n predefined:\n - A\n", encoding="utf-8")lines 686–686with pytest.raises(DeclarationError, match="preprocessors")lines 687–687load_declaration(root)

test_a_repo_with_its_own_predefined_is_not_overridden

None test_preprocessor.test_a_repo_with_its_own_predefined_is_not_overridden(Path tmp_path)

A repo whose own Doxyfile sets PREDEFINED keeps it, and gains ours.

tests/test_preprocessor.py:310

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo

Checks

  • assert "feature_entry" in functions, ("the repo's OWN Doxyfile PREDEFINED was discarded — PREDEFINED = rather than +=" )
  • assert "wide_entry" in functions, "the declared macro did not reach doxygen"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-012measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-013measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 23 lines
def test_a_repo_with_its_own_predefined_is_not_overridden(tmp_path: Path) -> None:
    """The regression this guards is a one-character one. Doxygen takes the LAST
    assignment to a key, so emitting `PREDEFINED =` instead of `PREDEFINED +=` would
    silently DISCARD the list a target's own Doxyfile declares — turning a feature that
    widens an index into one that narrows it, for exactly the repos already doing the
    right thing, with no error anywhere.

    So the Doxyfile declares `FIXTURE_FEATURE_C` and the declaration adds
    `FIXTURE_WIDTH=16`: both functions must index. Asserting only on the declared macro
    would pass under `=` as well.
    """
    root = _fixture_repo(
        tmp_path,
        declaration="preprocessor:\n  predefined:\n    - FIXTURE_WIDTH=16\n",
        doxyfile_extra="PREDEFINED = FIXTURE_FEATURE_C\n",
    )
    functions = _doxygen_functions(_build(root, tmp_path / "out.db"))
    assert "feature_entry" in functions, (
        "the repo's OWN Doxyfile PREDEFINED was discarded — PREDEFINED = rather than +="
    )
    assert "wide_entry" in functions, "the declared macro did not reach doxygen"

Activity · 4 steps
lines 321–325root = _fixture_repo( tmp_path, declaration="preprocessor:\n predefined:\n - FIXTURE_WIDTH=16\n", doxyfile_extra="PREDEFINED = FIXTURE_FEATURE_C\n", )lines 326–326functions = _doxygen_functions(_build(root, tmp_path / "out.db"))lines 327–329assert "feature_entry" in functions, ( "the repo's OWN Doxyfile PREDEFINED was discarded — PREDEFINED = rather than +=" )lines 330–330assert "wide_entry" in functions, "the declared macro did not reach doxygen"

test_a_scalar_predefined_is_refused

None test_preprocessor.test_a_scalar_predefined_is_refused(Path tmp_path)

A non-list predefined: is refused rather than iterated character by character.

tests/test_preprocessor.py:647

Checks

  • assert config.macros == (), "a scalar was coerced into per-character macros"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_a_scalar_predefined_is_refused → resolve_preprocessor
REQ-DDB-PIPE-014catalogtest_a_scalar_predefined_is_refused → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 11 lines
def test_a_scalar_predefined_is_refused(tmp_path: Path) -> None:
    """A string here would otherwise be iterated CHARACTER BY CHARACTER into a hundred
    one-letter macros — a build that succeeds while feeding doxygen nonsense, which is
    strictly worse than ignoring the key.
    """
    root = tmp_path / "repo"
    root.mkdir()
    config = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"predefined": "FIXTURE_A"}})
    assert config.macros == (), "a scalar was coerced into per-character macros"

Activity · 4 steps
lines 652–652root = tmp_path / "repo"lines 653–653root.mkdir()lines 654–654config = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"predefined": "FIXTURE_A"}})lines 655–655assert config.macros == (), "a scalar was coerced into per-character macros"

test_an_explicit_flag_replaces_the_declaration

None test_preprocessor.test_an_explicit_flag_replaces_the_declaration(Path tmp_path)

A stated predefined overrides the repo's declaration outright.

tests/test_preprocessor.py:338

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo

Checks

  • assert "wide_entry" in functions, "the stated macro did not reach doxygen"
  • assert "feature_entry" not in functions, ("the statement MERGED with the declaration instead of replacing it" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-GUARD-012measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-013measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 27 lines
def test_an_explicit_flag_replaces_the_declaration(tmp_path: Path) -> None:
    """A STATED `predefined` REPLACES rather than merges, matching `entry_patterns`. The
    declaration is the repo's standing statement about which variant it ships; an
    operator stating macros is deliberately indexing a different one, and merging would
    produce a third configuration nobody asked for. So the declared `FIXTURE_FEATURE_C`
    must be GONE, which is the half that distinguishes replacement from union.

    STATED THROUGH `options` NOW THAT `--predefined` IS GONE (22->6 collapse), and the
    semantics are unchanged because the route lands on the same dest — which is the whole
    claim of the fold and the reason this test is the one that proves it. The provenance
    filter in `_doxygen_functions` is what makes it capable of proving anything: after a lost
    `predefined` the symbol is STILL in `memberdef` as `dg_source='ast'` (gh#11 recovers it
    from the source text), with no brief and no params, so a presence check reports healthy.
    """
    root = _fixture_repo(
        tmp_path,
        declaration="preprocessor:\n  predefined:\n    - FIXTURE_FEATURE_C\n",
    )
    functions = _doxygen_functions(
        _build(root, tmp_path / "out.db", {"predefined": ["FIXTURE_WIDTH=16"]})
    )
    assert "wide_entry" in functions, "the stated macro did not reach doxygen"
    assert "feature_entry" not in functions, (
        "the statement MERGED with the declaration instead of replacing it"
    )

Activity · 4 steps
lines 352–355root = _fixture_repo( tmp_path, declaration="preprocessor:\n predefined:\n - FIXTURE_FEATURE_C\n", )lines 356–358functions = _doxygen_functions( _build(root, tmp_path / "out.db", {"predefined": ["FIXTURE_WIDTH=16"]}) )lines 359–359assert "wide_entry" in functions, "the stated macro did not reach doxygen"lines 360–362assert "feature_entry" not in functions, ( "the statement MERGED with the declaration instead of replacing it" )

test_an_explicit_list_keeps_the_declared_config_header

None test_preprocessor.test_an_explicit_list_keeps_the_declared_config_header(Path tmp_path)

An explicit macro list overrides the macros WITHOUT discarding the declared header.

tests/test_preprocessor.py:806

Checks

  • assert config.source == SOURCE_FLAG, "an explicit list still wins outright"
  • assert config.macros == ('"SHIPPED_OFF"',), (f"the override must replace the macro list, not merge the header into it; got " f"{config.macros}" )
  • assert config.config_header == "include/config.h", ("the declared header was discarded by the explicit branch — the defect this test exists " "for. It is a fact about the repository and survives an override of the macro list." )
  • assert config.stated_only == ("SHIPPED_OFF",), (f"`stated_only` must name the overridden macros the header does not define, which is what " f"lets the reply say they ship OFF; got {config.stated_only}" )
  • assert both.stated_only == ("SHIPPED_OFF",), (f"SHIPPED_ON is defined in the header, so it must not be listed as operator-only; got " f"{both.stated_only}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_an_explicit_list_keeps_the_declared_config_header → resolve_preprocessor
REQ-DDB-PIPE-014measuredtest_an_explicit_list_keeps_the_declared_config_header → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 55 lines
def test_an_explicit_list_keeps_the_declared_config_header(tmp_path: Path) -> None:
    """THE ACCEPTANCE BUILD DISCARDED ITS OWN DECLARED HEADER ON EVERY RUN. `resolve_preprocessor`
    returned on `if explicit:` before reading the declaration at all, so a `config_header:` stated
    in the SAME section as `predefined:` was silently dropped the moment a macro list was passed —
    and `clew/cli.py` promotes a declared `predefined:` to exactly that argument. An
    accepted-but-unread key is this project's most repeated defect; this was an instance.

    WHAT THE FLAG LEGITIMATELY OVERRIDES IS THE MACRO LIST, and that is still asserted below: the
    override wins, `source` stays `flag`, and the header is not merged into `macros`. Where the
    repository states its own defaults is a fact ABOUT THE REPOSITORY and does not become untrue
    because the operator indexed a different variant.

    THAT IS WHAT MAKES `stated_only` COMPUTABLE, which is the payoff: the overridden names the
    header does NOT define are exactly the ones that ship OFF, and that is the sentence two graded
    marks ask for.

    @brief An explicit list overrides macros and keeps the declared header and split.
    @return None.
    @version 1
    """
    root = tmp_path / "repo"
    (root / "include").mkdir(parents=True)
    (root / "include" / "config.h").write_text(
        "#define SHIPPED_ON 1\n//#define SHIPPED_OFF\n", encoding="utf-8"
    )
    declaration = {
        SECTION_PREPROCESSOR: {
            "predefined": ["SHIPPED_OFF"],
            "config_header": "include/config.h",
        }
    }

    config = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF"])

    assert config.source == SOURCE_FLAG, "an explicit list still wins outright"
    assert config.macros == ('"SHIPPED_OFF"',), (
        f"the override must replace the macro list, not merge the header into it; got "
        f"{config.macros}"
    )
    assert config.config_header == "include/config.h", (
        "the declared header was discarded by the explicit branch — the defect this test exists "
        "for. It is a fact about the repository and survives an override of the macro list."
    )
    assert config.stated_only == ("SHIPPED_OFF",), (
        f"`stated_only` must name the overridden macros the header does not define, which is what "
        f"lets the reply say they ship OFF; got {config.stated_only}"
    )
    ## THE NEGATIVE HALF: a macro the header DOES define must not be reported as shipping off.
    both = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF", "SHIPPED_ON"])
    assert both.stated_only == ("SHIPPED_OFF",), (
        f"SHIPPED_ON is defined in the header, so it must not be listed as operator-only; got "
        f"{both.stated_only}"
    )

Activity · 11 steps
lines 826–826root = tmp_path / "repo"lines 827–827(root / "include").mkdir(parents=True)lines 828–830(root / "include" / "config.h").write_text( "#define SHIPPED_ON 1\n//#define SHIPPED_OFF\n", encoding="utf-8" )lines 831–836declaration = { SECTION_PREPROCESSOR: { "predefined": ["SHIPPED_OFF"], "config_header": "include/config.h", } }lines 838–838config = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF"])lines 840–840assert config.source == SOURCE_FLAG, "an explicit list still wins outright"lines 841–844assert config.macros == ('"SHIPPED_OFF"',), ( f"the override must replace the macro list, not merge the header into it; got " f"{config.macros}" )lines 845–848assert config.config_header == "include/config.h", ( "the declared header was discarded by the explicit branch — the defect this test exists " "for. It is a fact about the repository and survives an override of the macro list." )lines 849–852assert config.stated_only == ("SHIPPED_OFF",), ( f"`stated_only` must name the overridden macros the header does not define, which is what " f"lets the reply say they ship OFF; got {config.stated_only}" )lines 854–854both = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF", "SHIPPED_ON"])lines 855–858assert both.stated_only == ("SHIPPED_OFF",), ( f"SHIPPED_ON is defined in the header, so it must not be listed as operator-only; got " f"{both.stated_only}" )

test_an_undeclared_configuration_decides_nothing

None test_preprocessor.test_an_undeclared_configuration_decides_nothing()

With nothing declared, every guard is UNKNOWN rather than dead.

tests/test_preprocessor.py:791

Show on the map →

Called by none

Calls none

Checks

  • assert cfg.declared is False
  • assert cfg.defined_names == frozenset()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measured
REQ-DDB-PIPE-014catalog
Source · 11 lines
def test_an_undeclared_configuration_decides_nothing() -> None:
    """A target that declares no configuration must not have its conditional bindings
    read as dead — that would empty the layer. `defined(X)` against an empty set is
    legitimately False for the DOXYGEN parse, but for BRANCH SELECTION the honest verdict
    is that we were told nothing, which the emitter reads off `declared` rather than off
    this function."""
    cfg = PreprocessorConfig()
    assert cfg.declared is False
    assert cfg.defined_names == frozenset()

Activity · 3 steps
lines 797–797cfg = PreprocessorConfig()lines 798–798assert cfg.declared is Falselines 799–799assert cfg.defined_names == frozenset()

test_an_undeclared_target_is_untouched

None test_preprocessor.test_an_undeclared_target_is_untouched(Path tmp_path)

A target declaring nothing records no preprocessor rows and indexes as before.

tests/test_preprocessor.py:370

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo, _meta

Checks

  • assert "feature_entry" not in _doxygen_functions(db)
  • assert _meta(db, "preprocessor") == {}, "an undeclared target wrote preprocessor rows"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001measured
REQ-DDB-CONFIG-001measured
REQ-DDB-CONFIG-004measured
REQ-DDB-CONFIG-005measured
REQ-DDB-CONFIG-006measured
REQ-DDB-CONFIG-007measured
REQ-DDB-CONFIG-009measured
REQ-DDB-INDEX-001measured
REQ-DDB-INDEX-002measured
REQ-DDB-INDEX-003measured
REQ-DDB-INDEX-004measured
REQ-DDB-INDEX-005measured
REQ-DDB-INDEX-006measured
REQ-DDB-INDEX-007measured
REQ-DDB-INDEX-008measured
REQ-DDB-INDEX-009measured
REQ-DDB-INDEX-010measured
REQ-DDB-INDEX-011measured
REQ-DDB-MCP-001measured
REQ-DDB-MCP-004measured
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-004measured
REQ-DDB-PIPE-005measured
REQ-DDB-PIPE-006measured
REQ-DDB-PIPE-007measured
REQ-DDB-PIPE-008measured
REQ-DDB-PIPE-009measured
REQ-DDB-PIPE-010measured
REQ-DDB-PIPE-011measured
REQ-DDB-PIPE-012measured
REQ-DDB-PIPE-013measured
REQ-DDB-PIPE-014measured
REQ-DDB-PIPE-015measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-011measured
REQ-DDB-QUERY-013measured
REQ-DDB-SCHEMA-001measured
REQ-DDB-SCHEMA-002measured
REQ-DDB-SCHEMA-003measured
REQ-DDB-SCHEMA-004measured
REQ-DDB-SCHEMA-005measured
REQ-DDB-SCHEMA-006measured
REQ-DDB-SCHEMA-007measured
REQ-DDB-SCHEMA-009measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-SCHEMA-012measured
REQ-DDB-SCHEMA-013measured
REQ-DDB-SCHEMA-014measured
REQ-DDB-SCHEMA-015measured
Source · 17 lines
def test_an_undeclared_target_is_untouched(tmp_path: Path) -> None:
    """The inertness guarantee. gh#17 must not change what any existing target indexes,
    and an absent `preprocessor.*` section is what makes the recorded provenance honest —
    a missing key reads as "not recorded", where `source=none` would read as a decision
    that was made.
    """
    root = _fixture_repo(tmp_path)
    db = _build(root, tmp_path / "out.db")
    assert "feature_entry" not in _doxygen_functions(db)
    assert _meta(db, "preprocessor") == {}, "an undeclared target wrote preprocessor rows"


# --------------------------------------------------------------------------- #
# The content tier: the Doxyfile text, and the cache hash computed over it.
# --------------------------------------------------------------------------- #

Activity · 4 steps
lines 376–376root = _fixture_repo(tmp_path)lines 377–377db = _build(root, tmp_path / "out.db")lines 378–378assert "feature_entry" not in _doxygen_functions(db)lines 379–379assert _meta(db, "preprocessor") == {}, "an undeclared target wrote preprocessor rows"

test_auto_discovery_finds_one_conventional_header

None test_preprocessor.test_auto_discovery_finds_one_conventional_header(Path tmp_path)

config_header: auto finds a single conventional header.

tests/test_preprocessor.py:506

Checks

  • assert config.macros == ('"CONFIG_FOO=1"',)
  • assert config.config_header == "include/generated/autoconf.h"
  • assert config.source == SOURCE_CONFIG_HEADER

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_auto_discovery_finds_one_conventional_header → resolve_preprocessor
REQ-DDB-PIPE-014catalogtest_auto_discovery_finds_one_conventional_header → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 18 lines
def test_auto_discovery_finds_one_conventional_header(tmp_path: Path) -> None:
    """`auto` is OPT-IN, and this is the case it exists for: a Kconfig build has written
    `include/generated/autoconf.h` and the owner wants the index to represent it without
    restating the path.
    """
    root = tmp_path / "repo"
    (root / "include" / "generated").mkdir(parents=True)
    (root / "include" / "generated" / "autoconf.h").write_text(
        "#define CONFIG_FOO 1\n", encoding="utf-8"
    )
    config = resolve_preprocessor(
        root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}}
    )
    assert config.macros == ('"CONFIG_FOO=1"',)
    assert config.config_header == "include/generated/autoconf.h"
    assert config.source == SOURCE_CONFIG_HEADER

Activity · 7 steps
lines 511–511root = tmp_path / "repo"lines 512–512(root / "include" / "generated").mkdir(parents=True)lines 513–515(root / "include" / "generated" / "autoconf.h").write_text( "#define CONFIG_FOO 1\n", encoding="utf-8" )lines 516–518config = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}} )lines 519–519assert config.macros == ('"CONFIG_FOO=1"',)lines 520–520assert config.config_header == "include/generated/autoconf.h"lines 521–521assert config.source == SOURCE_CONFIG_HEADER

test_auto_discovery_ignores_a_mock_config_header

None test_preprocessor.test_auto_discovery_ignores_a_mock_config_header(Path tmp_path)

Auto discovery never reaches a test/mock config header.

tests/test_preprocessor.py:554

Checks

  • assert discovered.macros == (), "discovery reached a mock config header"
  • assert named.macros == ('"MOCK_ONLY=1"',), "an explicitly named header must be honoured"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_auto_discovery_ignores_a_mock_config_header → resolve_preprocessor
REQ-DDB-PIPE-014measuredtest_auto_discovery_ignores_a_mock_config_header → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 25 lines
def test_auto_discovery_ignores_a_mock_config_header(tmp_path: Path) -> None:
    """Many Kconfig projects ship a hand-written mock config header for unit tests.
    Discovering it would index a configuration NOBODY SHIPS, wearing the authority of a
    recorded declaration — so no conventional location lies under a test directory, and
    a `*_config.h` glob (which gh#17 floats) is deliberately absent for the same reason.

    Naming that file explicitly still works, and is the intended escape hatch: then the
    choice was made by a person and `preprocessor.config_header` records it.
    """
    root = tmp_path / "repo"
    (root / "tests" / "include").mkdir(parents=True)
    mock = root / "tests" / "include" / "mock_config.h"
    mock.write_text("#define MOCK_ONLY 1\n", encoding="utf-8")

    discovered = resolve_preprocessor(
        root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}}
    )
    assert discovered.macros == (), "discovery reached a mock config header"

    named = resolve_preprocessor(
        root, {SECTION_PREPROCESSOR: {"config_header": "tests/include/mock_config.h"}}
    )
    assert named.macros == ('"MOCK_ONLY=1"',), "an explicitly named header must be honoured"

Activity · 8 steps
lines 563–563root = tmp_path / "repo"lines 564–564(root / "tests" / "include").mkdir(parents=True)lines 565–565mock = root / "tests" / "include" / "mock_config.h"lines 566–566mock.write_text("#define MOCK_ONLY 1\n", encoding="utf-8")lines 568–570discovered = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}} )lines 571–571assert discovered.macros == (), "discovery reached a mock config header"lines 573–575named = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"config_header": "tests/include/mock_config.h"}} )lines 576–576assert named.macros == ('"MOCK_ONLY=1"',), "an explicitly named header must be honoured"

test_auto_discovery_refuses_two_candidates

None test_preprocessor.test_auto_discovery_refuses_two_candidates(Path tmp_path)

config_header: auto REFUSES when two conventional headers exist.

tests/test_preprocessor.py:528

Checks

  • assert config.macros == (), "discovery guessed among two candidates"
  • assert config.declared, "a refusal must still record that a configuration was declared"
  • assert config.searched, "a refusal must name where it looked"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_auto_discovery_refuses_two_candidates → resolve_preprocessor
REQ-DDB-PIPE-014catalogtest_auto_discovery_refuses_two_candidates → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 22 lines
def test_auto_discovery_refuses_two_candidates(tmp_path: Path) -> None:
    """Follows `discover_doxyfile`, and the stakes here are higher than there.
    Choosing the wrong config header does not merely
    index the wrong FILES — it indexes a different VARIANT of the right ones, and every
    count taken from the result still looks legitimate.

    `declared` stays True while `macros` is empty, which is the whole of part 3's value:
    the resulting zero is attributable to a refusal rather than reading as "the owner
    said nothing".
    """
    root = tmp_path / "repo"
    root.mkdir()
    (root / "autoconf.h").write_text("#define FROM_AUTOCONF 1\n", encoding="utf-8")
    (root / "config.h").write_text("#define FROM_CONFIG 1\n", encoding="utf-8")
    config = resolve_preprocessor(
        root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}}
    )
    assert config.macros == (), "discovery guessed among two candidates"
    assert config.declared, "a refusal must still record that a configuration was declared"
    assert config.searched, "a refusal must name where it looked"

Activity · 8 steps
lines 538–538root = tmp_path / "repo"lines 539–539root.mkdir()lines 540–540(root / "autoconf.h").write_text("#define FROM_AUTOCONF 1\n", encoding="utf-8")lines 541–541(root / "config.h").write_text("#define FROM_CONFIG 1\n", encoding="utf-8")lines 542–544config = resolve_preprocessor( root, {SECTION_PREPROCESSOR: {"config_header": CONFIG_HEADER_AUTO}} )lines 545–545assert config.macros == (), "discovery guessed among two candidates"lines 546–546assert config.declared, "a refusal must still record that a configuration was declared"lines 547–547assert config.searched, "a refusal must name where it looked"

test_defined_names_strips_quoting_and_values

None test_preprocessor.test_defined_names_strips_quoting_and_values()

defined_names strips doxygen token quoting and any =value .

tests/test_preprocessor.py:693

Show on the map →

Called by none

Calls none

Checks

  • assert cfg.defined_names == frozenset({"MBEDTLS_THREADING_PTHREAD", "MBEDTLS_X"})

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measured
REQ-DDB-PIPE-014catalog
Source · 11 lines
def test_defined_names_strips_quoting_and_values() -> None:
    """gh#35 asks "is X defined" of a field built to render a Doxyfile, so its entries are
    `'"NAME"'` / `'"NAME=v"'` with the quotes in the string. A caller doing that stripping
    itself is a caller that can drift; this pins the one place it happens.

    A macro defined to `0` is DEFINED — that is what `defined(X)` means — and conflating
    it with undefined would pick the wrong branch."""
    cfg = PreprocessorConfig(macros=('"MBEDTLS_THREADING_PTHREAD"', '"MBEDTLS_X=0"'))
    assert cfg.defined_names == frozenset({"MBEDTLS_THREADING_PTHREAD", "MBEDTLS_X"})

Activity · 2 steps
lines 700–700cfg = PreprocessorConfig(macros=('"MBEDTLS_THREADING_PTHREAD"', '"MBEDTLS_X=0"'))lines 701–701assert cfg.defined_names == frozenset({"MBEDTLS_THREADING_PTHREAD", "MBEDTLS_X"})

test_evaluate_condition_decides_defined_atoms

None test_preprocessor.test_evaluate_condition_decides_defined_atoms()

A defined atom is decided both ways, and negation inverts it.

tests/test_preprocessor.py:707

Checks

  • assert evaluate_condition("defined(A)", on) is True
  • assert evaluate_condition("defined A", on) is True
  • assert evaluate_condition("defined(B)", on) is False
  • assert evaluate_condition("!defined(A)", on) is False
  • assert evaluate_condition("!defined(B)", on) is True

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_evaluate_condition_decides_defined_atoms → evaluate_condition
REQ-DDB-PIPE-014catalog
Source · 10 lines
def test_evaluate_condition_decides_defined_atoms() -> None:
    """The two forms real code uses, plus `#ifdef`'s normalised spelling."""
    on = frozenset({"A"})
    assert evaluate_condition("defined(A)", on) is True
    assert evaluate_condition("defined A", on) is True
    assert evaluate_condition("defined(B)", on) is False
    assert evaluate_condition("!defined(A)", on) is False
    assert evaluate_condition("!defined(B)", on) is True

Activity · 6 steps
lines 709–709on = frozenset({"A"})lines 710–710assert evaluate_condition("defined(A)", on) is Truelines 711–711assert evaluate_condition("defined A", on) is Truelines 712–712assert evaluate_condition("defined(B)", on) is Falselines 713–713assert evaluate_condition("!defined(A)", on) is Falselines 714–714assert evaluate_condition("!defined(B)", on) is True

test_evaluate_condition_folds_boolean_operators

None test_preprocessor.test_evaluate_condition_folds_boolean_operators()

AND and OR fold with C's precedence and parenthesised groups.

tests/test_preprocessor.py:720

Checks

  • assert evaluate_condition("defined(A) && defined(C)", on) is True
  • assert evaluate_condition("defined(A) && defined(B)", on) is False
  • assert evaluate_condition("defined(B) || defined(C)", on) is True
  • assert evaluate_condition("defined(A) && defined(B) || defined(C)", on) is True
  • assert evaluate_condition("defined(A) && (defined(B) || defined(C))", on) is True
  • assert evaluate_condition("(defined(B) || defined(D))", on) is False
  • assert evaluate_condition("(defined(A)) && (defined(C))", on) is True
  • assert evaluate_condition("(defined(A)) && (defined(B))", on) is False

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_evaluate_condition_folds_boolean_operators → evaluate_condition
REQ-DDB-PIPE-014catalog
Source · 17 lines
def test_evaluate_condition_folds_boolean_operators() -> None:
    """`||` binds looser than `&&`, so `defined(A) && defined(B) || defined(C)` is
    `(A&&B) || C`. Splitting on `&&` first would read it as `A && (B||C)` and give the
    opposite answer for A undefined, C defined."""
    on = frozenset({"A", "C"})
    assert evaluate_condition("defined(A) && defined(C)", on) is True
    assert evaluate_condition("defined(A) && defined(B)", on) is False
    assert evaluate_condition("defined(B) || defined(C)", on) is True
    assert evaluate_condition("defined(A) && defined(B) || defined(C)", on) is True
    assert evaluate_condition("defined(A) && (defined(B) || defined(C))", on) is True
    assert evaluate_condition("(defined(B) || defined(D))", on) is False
    # `(X) && (Y)` also starts with `(` and ends with `)`. A parenthesis-stripper that
    # tested only startswith/endswith would mangle it into `X) && (Y` and read UNKNOWN.
    assert evaluate_condition("(defined(A)) && (defined(C))", on) is True
    assert evaluate_condition("(defined(A)) && (defined(B))", on) is False

Activity · 9 steps
lines 724–724on = frozenset({"A", "C"})lines 725–725assert evaluate_condition("defined(A) && defined(C)", on) is Truelines 726–726assert evaluate_condition("defined(A) && defined(B)", on) is Falselines 727–727assert evaluate_condition("defined(B) || defined(C)", on) is Truelines 728–728assert evaluate_condition("defined(A) && defined(B) || defined(C)", on) is Truelines 729–729assert evaluate_condition("defined(A) && (defined(B) || defined(C))", on) is Truelines 730–730assert evaluate_condition("(defined(B) || defined(D))", on) is Falselines 733–733assert evaluate_condition("(defined(A)) && (defined(C))", on) is Truelines 734–734assert evaluate_condition("(defined(A)) && (defined(B))", on) is False

test_evaluate_condition_reports_unknown_rather_than_guessing

None test_preprocessor.test_evaluate_condition_reports_unknown_rather_than_guessing()

An expression the evaluator cannot read is UNKNOWN, never False.

tests/test_preprocessor.py:740

Checks

  • assert evaluate_condition("_POSIX_VERSION >= 200809L", on) is None
  • assert evaluate_condition("A", on) is None
  • assert evaluate_condition("__has_include(<foo.h>)", on) is None
  • assert evaluate_condition("!(A + 1)", on) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_evaluate_condition_reports_unknown_rather_than_guessing → evaluate_condition
REQ-DDB-PIPE-014catalog
Source · 15 lines
def test_evaluate_condition_reports_unknown_rather_than_guessing() -> None:
    """THE LOAD-BEARING CASE for gh#35. None means "we do not know which branch is live",
    and it must never collapse to False — a False here would DELETE the live edge of every
    binding guarded by an expression this evaluator cannot parse, which is worse than the
    over-complete graph gh#35 is fixing.

    Arithmetic, comparisons, a bare `#if X` read as a value, and `__has_include` are all
    real `#if` grammar and all outside what a `defined`-only evaluator can settle."""
    on = frozenset({"A"})
    assert evaluate_condition("_POSIX_VERSION >= 200809L", on) is None
    assert evaluate_condition("A", on) is None
    assert evaluate_condition("__has_include(<foo.h>)", on) is None
    assert evaluate_condition("!(A + 1)", on) is None

Activity · 5 steps
lines 748–748on = frozenset({"A"})lines 749–749assert evaluate_condition("_POSIX_VERSION >= 200809L", on) is Nonelines 750–750assert evaluate_condition("A", on) is Nonelines 751–751assert evaluate_condition("__has_include(<foo.h>)", on) is Nonelines 752–752assert evaluate_condition("!(A + 1)", on) is None

test_no_declaration_emits_no_doxyfile_lines

None test_preprocessor.test_no_declaration_emits_no_doxyfile_lines(Path tmp_path)

An undeclared target's Doxyfile text is byte-identical to the pre-gh#17 text.

tests/test_preprocessor.py:426

Show on the map →

Called by none

Calls _fixture_repo, doxyfile_content_for

Checks

  • assert "PREDEFINED" not in content
  • assert "ENABLE_PREPROCESSING" not in content
  • assert content == doxyfile_content_for(root / "Doxyfile", predefined="")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004catalog
REQ-DDB-INDEX-001measuredtest_no_declaration_emits_no_doxyfile_lines → doxyfile_content_for
REQ-DDB-PIPE-003measuredtest_no_declaration_emits_no_doxyfile_lines → doxyfile_content_for → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-014catalog
Source · 13 lines
def test_no_declaration_emits_no_doxyfile_lines(tmp_path: Path) -> None:
    """The other half of inertness, and the one a build test cannot show: not merely
    that an undeclared target indexes the same rows, but that doxygen is fed the same
    BYTES. `ENABLE_PREPROCESSING` is checked by name because forcing it unconditionally
    would be an invisible policy change on every existing target.
    """
    root = _fixture_repo(tmp_path)
    content = doxyfile_content_for(root / "Doxyfile")
    assert "PREDEFINED" not in content
    assert "ENABLE_PREPROCESSING" not in content
    assert content == doxyfile_content_for(root / "Doxyfile", predefined="")

Activity · 5 steps
lines 432–432root = _fixture_repo(tmp_path)lines 433–433content = doxyfile_content_for(root / "Doxyfile")lines 434–434assert "PREDEFINED" not in contentlines 435–435assert "ENABLE_PREPROCESSING" not in contentlines 436–436assert content == doxyfile_content_for(root / "Doxyfile", predefined="")

test_provenance_names_the_source

None test_preprocessor.test_provenance_names_the_source(Path tmp_path)

Provenance distinguishes flag, declaration, header and nothing.

tests/test_preprocessor.py:629

Checks

  • assert resolve_preprocessor(root, {}).source == SOURCE_NONE
  • assert resolve_preprocessor(root, {}, ["A"]).source == SOURCE_FLAG
  • assert declared.source == SOURCE_DECLARED
  • assert declared.as_meta()["predefined"] == '"A"'

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_provenance_names_the_source → resolve_preprocessor
REQ-DDB-PIPE-014catalogtest_provenance_names_the_source → resolve_preprocessor → _resolve_config_header → _named_config_header → within_repo
Source · 14 lines
def test_provenance_names_the_source(tmp_path: Path) -> None:
    """Part 3's actual claim. Every one of these must be distinguishable in `build_meta`,
    because an index of a multi-variant codebase is an index of ONE variant and a
    consumer comparing two indexes needs to know which.
    """
    root = tmp_path / "repo"
    root.mkdir()
    assert resolve_preprocessor(root, {}).source == SOURCE_NONE
    assert resolve_preprocessor(root, {}, ["A"]).source == SOURCE_FLAG
    declared = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"predefined": ["A"]}})
    assert declared.source == SOURCE_DECLARED
    assert declared.as_meta()["predefined"] == '"A"'

Activity · 7 steps
lines 634–634root = tmp_path / "repo"lines 635–635root.mkdir()lines 636–636assert resolve_preprocessor(root, {}).source == SOURCE_NONElines 637–637assert resolve_preprocessor(root, {}, ["A"]).source == SOURCE_FLAGlines 638–638declared = resolve_preprocessor(root, {SECTION_PREPROCESSOR: {"predefined": ["A"]}})lines 639–639assert declared.source == SOURCE_DECLAREDlines 640–640assert declared.as_meta()["predefined"] == '"A"'

test_rendered_lines_append_and_quote

None test_preprocessor.test_rendered_lines_append_and_quote()

Rendered Doxyfile text appends rather than assigns, and quotes every token.

tests/test_preprocessor.py:442

Checks

  • assert "PREDEFINED = " not in text, "assignment would discard the target's own list"
  • assert 'PREDEFINED += "A"' in text
  • assert 'PREDEFINED += "B=1 + 2"' in text
  • assert "ENABLE_PREPROCESSING = YES" in text, "PREDEFINED has no effect without it"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_rendered_lines_append_and_quote → doxyfile_lines
REQ-DDB-PIPE-014catalog
Source · 17 lines
def test_rendered_lines_append_and_quote() -> None:
    """Pins the two properties the build tests depend on but cannot isolate. `+=` is the
    reason a target's own PREDEFINED survives; quoting is the reason a value containing
    a space stays ONE macro rather than becoming three entries, two of them nonsense.
    """
    text = doxyfile_lines(PreprocessorConfig(macros=('"A"', '"B=1 + 2"')))
    assert "PREDEFINED = " not in text, "assignment would discard the target's own list"
    assert 'PREDEFINED += "A"' in text
    assert 'PREDEFINED += "B=1 + 2"' in text
    assert "ENABLE_PREPROCESSING = YES" in text, "PREDEFINED has no effect without it"


# --------------------------------------------------------------------------- #
# Header harvesting, discovery, and the refusals.
# --------------------------------------------------------------------------- #

Activity · 5 steps
lines 447–447text = doxyfile_lines(PreprocessorConfig(macros=('"A"', '"B=1 + 2"')))lines 448–448assert "PREDEFINED = " not in text, "assignment would discard the target's own list"lines 449–449assert 'PREDEFINED += "A"' in textlines 450–450assert 'PREDEFINED += "B=1 + 2"' in textlines 451–451assert "ENABLE_PREPROCESSING = YES" in text, "PREDEFINED has no effect without it"

test_the_declaration_works_beside_the_guard_section

None test_preprocessor.test_the_declaration_works_beside_the_guard_section(Path tmp_path)

The declaration is read from a .clew.yaml that also configures the gate.

tests/test_preprocessor.py:257

Show on the map →

Called by none

Calls _build, _doxygen_functions, _fixture_repo

Source · 22 lines
def test_the_declaration_works_beside_the_guard_section(tmp_path: Path) -> None:
    """One file carries both: the gate's `guard:` section and the index's declaration. The
    half most likely to rot silently is a declaration section that the shared file's
    `guard:` handling swallows, which no test against a declaration-only file would see.
    """
    root = _fixture_repo(
        tmp_path,
        declaration=(
            "guard:\n"
            "  validate:\n"
            "    tags:\n"
            "      req:\n"
            "        pattern: '^REQ-[0-9]+$'\n"
            "preprocessor:\n"
            "  predefined:\n"
            "    - FIXTURE_FEATURE_C\n"
        ),
    )
    functions = _doxygen_functions(_build(root, tmp_path / "out.db"))
    assert "feature_entry" in functions, "the preprocessor section beside guard: was not honoured"

Activity · 3 steps
lines 262–274root = _fixture_repo( tmp_path, declaration=( "guard:\n" " validate:\n" " tags:\n" " req:\n" " pattern: '^REQ-[0-9]+$'\n" "preprocessor:\n" " predefined:\n" " - FIXTURE_FEATURE_C\n" ), )lines 275–275functions = _doxygen_functions(_build(root, tmp_path / "out.db"))lines 276–276assert "feature_entry" in functions, "the preprocessor section beside guard: was not honoured"

test_the_header_scan_honours_undef_and_skips_the_unreadable

None test_preprocessor.test_the_header_scan_honours_undef_and_skips_the_unreadable(Path tmp_path)

The scan honours #undef and refuses what a line-at-a-time read cannot see.

tests/test_preprocessor.py:482

Checks

  • assert names == {"KEPT"}, f"unexpected macros harvested: {names}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_the_header_scan_honours_undef_and_skips_the_unreadable → macros_from_header
REQ-DDB-PIPE-014catalog
Source · 20 lines
def test_the_header_scan_honours_undef_and_skips_the_unreadable(tmp_path: Path) -> None:
    """Three refusals, each because a wrong answer here is worse than no answer.
    `#undef` must win, or a header that REVOKES a macro is read as defining it. A
    function-like macro is not a configuration statement. A continued macro cannot be
    read a line at a time, and half a value handed to doxygen as a whole one is a wrong
    answer wearing the shape of a right one.
    """
    header = tmp_path / "config.h"
    header.write_text(
        "#define KEPT 1\n"
        "#define REVOKED 1\n"
        "#undef REVOKED\n"
        "#define FUNCLIKE(x) ((x) + 1)\n"
        "#define CONTINUED a \\\n    b\n",
        encoding="utf-8",
    )
    names = {m.strip('"').split("=", 1)[0] for m in macros_from_header(header)}
    assert names == {"KEPT"}, f"unexpected macros harvested: {names}"

Activity · 4 steps
lines 489–489header = tmp_path / "config.h"lines 490–497header.write_text( "#define KEPT 1\n" "#define REVOKED 1\n" "#undef REVOKED\n" "#define FUNCLIKE(x) ((x) + 1)\n" "#define CONTINUED a \\\n b\n", encoding="utf-8", )lines 498–498names = {m.strip('"').split("=", 1)[0] for m in macros_from_header(header)}lines 499–499assert names == {"KEPT"}, f"unexpected macros harvested: {names}"

test_the_header_scan_reads_only_live_defines

None test_preprocessor.test_the_header_scan_reads_only_live_defines(Path tmp_path)

The header scan reads live defines and skips commented-out ones.

tests/test_preprocessor.py:463

Checks

  • assert '"FIXTURE_FEATURE_C"' in macros
  • assert '"FIXTURE_WIDTH=16"' in macros, "a trailing block comment leaked into the value"
  • assert not any("DISABLED" in m for m in macros), "a commented-out define was harvested"
  • assert '"FIXTURE_CONFIG_H"' in macros, "the include guard is a define like any other"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_the_header_scan_reads_only_live_defines → macros_from_header
REQ-DDB-PIPE-014catalog
Source · 15 lines
def test_the_header_scan_reads_only_live_defines(tmp_path: Path) -> None:
    """The mbedtls idiom is a header of top-level defines with the alternatives COMMENTED
    OUT, so skipping `//#define` and `/* #define */` is not tidiness — it is the
    difference between reading the shipped configuration and reading every configuration
    the project supports at once.
    """
    header = tmp_path / "config.h"
    header.write_text(CONFIG_HEADER, encoding="utf-8")
    macros = macros_from_header(header)
    assert '"FIXTURE_FEATURE_C"' in macros
    assert '"FIXTURE_WIDTH=16"' in macros, "a trailing block comment leaked into the value"
    assert not any("DISABLED" in m for m in macros), "a commented-out define was harvested"
    assert '"FIXTURE_CONFIG_H"' in macros, "the include guard is a define like any other"

Activity · 7 steps
lines 469–469header = tmp_path / "config.h"lines 470–470header.write_text(CONFIG_HEADER, encoding="utf-8")lines 471–471macros = macros_from_header(header)lines 472–472assert '"FIXTURE_FEATURE_C"' in macroslines 473–473assert '"FIXTURE_WIDTH=16"' in macros, "a trailing block comment leaked into the value"lines 474–474assert not any("DISABLED" in m for m in macros), "a commented-out define was harvested"lines 475–475assert '"FIXTURE_CONFIG_H"' in macros, "the include guard is a define like any other"

test_the_index_cache_tree_hash_notices_a_changed_predefined

None test_preprocessor.test_the_index_cache_tree_hash_notices_a_changed_predefined(Path tmp_path)

The index-cache tree hash moves when the declared macros change.

tests/test_preprocessor.py:391

Show on the map →

Called by none

Calls _fixture_repo, doxyfile_content_for, doxyfile_lines

Checks

  • assert len(set(shas.values())) == 3, (f"the tree hash does not distinguish these configurations: {shas}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_the_index_cache_tree_hash_notices_a_changed_predefined → doxyfile_lines
REQ-DDB-INDEX-001measuredtest_the_index_cache_tree_hash_notices_a_changed_predefined → doxyfile_content_for
REQ-DDB-INDEX-002measured
REQ-DDB-PIPE-003measuredtest_the_index_cache_tree_hash_notices_a_changed_predefined → doxyfile_content_for → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-014catalog
Source · 31 lines
def test_the_index_cache_tree_hash_notices_a_changed_predefined(tmp_path: Path) -> None:
    """THE silent-wrong-answer test. A changed `preprocessor:` declaration touches no
    source file and no Doxyfile, so if the macro text reached the doxygen RUN but not the
    hash, editing the declared macros would replay the previous configuration's parse
    straight out of cache and report success — a well-formed index of the variant the
    owner just stopped declaring, with nothing anywhere saying so.

    Three hashes, not two: the unconfigured one must differ from both, and the two
    configured ones must differ from EACH OTHER. A hash that merely noticed "some macros
    exist" would pass a two-way test and still serve a stale parse on every edit after
    the first.
    """
    root = _fixture_repo(tmp_path)
    doxyfile = root / "Doxyfile"
    cache = IndexCache(tmp_path / "cache.db", Path(root))
    try:
        shas = {
            label: cache.tree_sha(doxyfile_content_for(doxyfile, predefined=text), [])
            for label, text in (
                ("none", ""),
                ("feature", doxyfile_lines(PreprocessorConfig(macros=('"FIXTURE_FEATURE_C"',)))),
                ("width", doxyfile_lines(PreprocessorConfig(macros=('"FIXTURE_WIDTH=16"',)))),
            )
        }
    finally:
        cache.close()
    assert len(set(shas.values())) == 3, (
        f"the tree hash does not distinguish these configurations: {shas}"
    )

Activity · 6 steps
lines 403–403root = _fixture_repo(tmp_path)lines 404–404doxyfile = root / "Doxyfile"lines 405–405cache = IndexCache(tmp_path / "cache.db", Path(root))lines 406–406trylines 407–414shas = { label: cache.tree_sha(doxyfile_content_for(doxyfile, predefined=text), []) for label, text in ( ("none", ""), ("feature", doxyfile_lines(PreprocessorConfig(macros=('"FIXTURE_FEATURE_C"',)))), ("width", doxyfile_lines(PreprocessorConfig(macros=('"FIXTURE_WIDTH=16"',)))), ) }lines 417–419assert len(set(shas.values())) == 3, ( f"the tree hash does not distinguish these configurations: {shas}" )

test_the_mbedtls_threading_guards_are_mutually_exclusive

None test_preprocessor.test_the_mbedtls_threading_guards_are_mutually_exclusive()

The two real mbedtls guards resolve oppositely under one configuration.

tests/test_preprocessor.py:773

Checks

  • assert evaluate_condition("defined(MBEDTLS_THREADING_C)", names) is True
  • assert evaluate_condition("defined(MBEDTLS_THREADING_PTHREAD)", names) is True
  • assert evaluate_condition("defined(MBEDTLS_THREADING_ALT)", names) is False

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_the_mbedtls_threading_guards_are_mutually_exclusive → evaluate_condition
REQ-DDB-PIPE-014catalog
Source · 15 lines
def test_the_mbedtls_threading_guards_are_mutually_exclusive() -> None:
    """gh#35's filed case, as written in `library/threading.c`: line 103 binds
    `threading_mutex_lock_pthread` under `defined(MBEDTLS_THREADING_PTHREAD)` and line 127
    binds `threading_mutex_fail` under `defined(MBEDTLS_THREADING_ALT)`. Exactly one holds
    in any real build, and this is the evaluation that lets the emitter say which."""
    cfg = PreprocessorConfig(
        macros=('"MBEDTLS_THREADING_C"', '"MBEDTLS_THREADING_PTHREAD"'),
        source=SOURCE_DECLARED,
    )
    names = cfg.defined_names
    assert evaluate_condition("defined(MBEDTLS_THREADING_C)", names) is True
    assert evaluate_condition("defined(MBEDTLS_THREADING_PTHREAD)", names) is True
    assert evaluate_condition("defined(MBEDTLS_THREADING_ALT)", names) is False

Activity · 5 steps
lines 778–781cfg = PreprocessorConfig( macros=('"MBEDTLS_THREADING_C"', '"MBEDTLS_THREADING_PTHREAD"'), source=SOURCE_DECLARED, )lines 782–782names = cfg.defined_nameslines 783–783assert evaluate_condition("defined(MBEDTLS_THREADING_C)", names) is Truelines 784–784assert evaluate_condition("defined(MBEDTLS_THREADING_PTHREAD)", names) is Truelines 785–785assert evaluate_condition("defined(MBEDTLS_THREADING_ALT)", names) is False

test_the_section_is_a_known_declaration_section

None test_preprocessor.test_the_section_is_a_known_declaration_section()

The section name is registered in the declaration allow-list.

tests/test_preprocessor.py:661

Show on the map →

Called by none

Calls none

Checks

  • assert SECTION_PREPROCESSOR in KNOWN_SECTIONS

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004catalog
REQ-DDB-PIPE-014catalog
Source · 10 lines
def test_the_section_is_a_known_declaration_section() -> None:
    """`declaration.KNOWN_SECTIONS` spells the name as its own literal, because
    `preprocessor.py` and `declaration.py` deliberately do not import each other. This
    pins the two spellings together, exactly as the existing `index_scope` test does — an
    unregistered section is REFUSED, so a drift here would make every declaration
    carrying it fail to load.
    """
    assert SECTION_PREPROCESSOR in KNOWN_SECTIONS

Activity · 1 steps
lines 668–668assert SECTION_PREPROCESSOR in KNOWN_SECTIONS

test_unknown_is_short_circuited_by_a_decisive_operand

None test_preprocessor.test_unknown_is_short_circuited_by_a_decisive_operand()

UNKNOWN beside a decisive operand does not weaken a known answer.

tests/test_preprocessor.py:758

Checks

  • assert evaluate_condition("defined(A) || _POSIX_VERSION >= 1", on) is True
  • assert evaluate_condition("defined(B) && _POSIX_VERSION >= 1", on) is False
  • assert evaluate_condition("defined(B) || _POSIX_VERSION >= 1", on) is None
  • assert evaluate_condition("defined(A) && _POSIX_VERSION >= 1", on) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-004measuredtest_unknown_is_short_circuited_by_a_decisive_operand → evaluate_condition
REQ-DDB-PIPE-014catalog
Source · 12 lines
def test_unknown_is_short_circuited_by_a_decisive_operand() -> None:
    """`defined(A) || <unreadable>` IS true when A is defined, and `defined(B) &&
    <unreadable>` IS false when B is not. Poisoning the whole expression with UNKNOWN
    would grade down edges whose branch really is determined — the false-weakening
    direction, which costs traversal in `mark_reachability` and the thread BFS."""
    on = frozenset({"A"})
    assert evaluate_condition("defined(A) || _POSIX_VERSION >= 1", on) is True
    assert evaluate_condition("defined(B) && _POSIX_VERSION >= 1", on) is False
    assert evaluate_condition("defined(B) || _POSIX_VERSION >= 1", on) is None
    assert evaluate_condition("defined(A) && _POSIX_VERSION >= 1", on) is None

Activity · 5 steps
lines 763–763on = frozenset({"A"})lines 764–764assert evaluate_condition("defined(A) || _POSIX_VERSION >= 1", on) is Truelines 765–765assert evaluate_condition("defined(B) && _POSIX_VERSION >= 1", on) is Falselines 766–766assert evaluate_condition("defined(B) || _POSIX_VERSION >= 1", on) is Nonelines 767–767assert evaluate_condition("defined(A) && _POSIX_VERSION >= 1", on) is None