test_an_explicit_list_keeps_the_declared_config_header¶
Tests › tests/test_preprocessor.py
What this test is for
Why it exists
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.
Given
root = tmp_path / "repo"(root / "include").mkdir(parents=True)
2 more
(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", } }
When
config = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF"])both = resolve_preprocessor(root, declaration, explicit=["SHIPPED_OFF", "SHIPPED_ON"])
Then
- ✓ config.source equals SOURCE_FLAG
- ✓ config.macros equals ('"SHIPPED_OFF"',)
- ✓ config.config_header equals "include/config.h"
- ✓ config.stated_only equals ("SHIPPED_OFF",)
- ✓ both.stated_only equals ("SHIPPED_OFF",)
tests/test_preprocessor.py:806 · its file's page
What it checks (5)
assert config.source == SOURCE_FLAG, "an explicit list still wins outright"observesresolve_preprocessorviaconfigassert config.macros == ('"SHIPPED_OFF"',), ( f"the override must replace the macro list, not merge the header into it; got " f"{config.macros}" )observesresolve_preprocessorviaconfigassert 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." )observesresolve_preprocessorviaconfigassert 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}" )observesresolve_preprocessorviaconfigassert 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}" )observesresolve_preprocessorviaboth
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-004 measured
- REQ-DDB-PIPE-014 measured