test_gate_coverage_integration.py¶
tests/integration/test_gate_coverage_integration.py
A function's PRECONDITIONS survive a real build, with the polarity intact.
test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently
None test_gate_coverage_integration.test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently(Path tmp_path)
A moved body is disclosed rather than passed off as the function's own.
tests/integration/test_gate_coverage_integration.py:247
Checks
assert fresh is not None and fresh.body is not None, "the fixture must produce a body"assert fresh.body.anchor_mismatch is False, (f"the tree is untouched, so the excerpt is the function's own — a mismatch here means the " f"check fires on ordinary code: {fresh.body.lines}" )assert any("drift_subject" in line for line in fresh.body.lines), ("and the excerpt really is anchored at the signature, which is what makes the check work" )assert moved is not None and moved.body is not Noneassert moved.body.anchor_mismatch is True, (f"the recorded span no longer holds this function, and saying nothing is what sent a " f"reader to the file: {moved.body.lines}" )assert moved.body.lines, ("the lines must still be returned — withholding the evidence is worse than labelling it, " "and a reader may still recognise what they are looking at" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | measured | |
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-004 | measured | |
| REQ-DDB-CONFIG-005 | measured | |
| REQ-DDB-CONFIG-006 | measured | |
| REQ-DDB-CONFIG-007 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-INDEX-001 | measured | |
| REQ-DDB-INDEX-002 | measured | |
| REQ-DDB-INDEX-003 | measured | |
| REQ-DDB-INDEX-004 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → symbol_provenance |
| REQ-DDB-INDEX-005 | measured | |
| REQ-DDB-INDEX-006 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-INDEX-008 | measured | |
| REQ-DDB-INDEX-009 | measured | |
| REQ-DDB-INDEX-010 | measured | |
| REQ-DDB-INDEX-011 | measured | |
| REQ-DDB-MCP-001 | measured | |
| REQ-DDB-MCP-004 | measured | |
| REQ-DDB-PIPE-001 | measured | |
| REQ-DDB-PIPE-003 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-004 | measured | |
| REQ-DDB-PIPE-005 | measured | |
| REQ-DDB-PIPE-006 | measured | |
| REQ-DDB-PIPE-007 | measured | |
| REQ-DDB-PIPE-008 | measured | |
| REQ-DDB-PIPE-009 | measured | |
| REQ-DDB-PIPE-010 | measured | |
| REQ-DDB-PIPE-011 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language |
| REQ-DDB-PIPE-013 | measured | |
| REQ-DDB-PIPE-014 | measured | |
| REQ-DDB-PIPE-015 | measured | |
| REQ-DDB-QUERY-001 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → connect |
| REQ-DDB-QUERY-002 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → unresolved_inbound_for_rowids |
| REQ-DDB-QUERY-003 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → function_candidates |
| REQ-DDB-QUERY-004 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier |
| REQ-DDB-QUERY-006 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → gates_covering |
| REQ-DDB-QUERY-009 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier |
| REQ-DDB-QUERY-010 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier |
| REQ-DDB-QUERY-011 | measured | |
| REQ-DDB-QUERY-012 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → _macro_dossier |
| REQ-DDB-QUERY-013 | inferred | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → config_defaults_conn |
| REQ-DDB-SCHEMA-001 | measured | |
| REQ-DDB-SCHEMA-002 | measured | |
| REQ-DDB-SCHEMA-003 | measured | |
| REQ-DDB-SCHEMA-004 | measured | |
| REQ-DDB-SCHEMA-005 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-007 | measured | |
| REQ-DDB-SCHEMA-009 | measured | |
| REQ-DDB-SCHEMA-011 | measured | test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently → function_dossier → _dossier_conn → locks_held_for_rowids |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-013 | measured | |
| REQ-DDB-SCHEMA-014 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 58 lines
def test_a_body_read_after_the_file_moved_is_disclosed_not_returned_silently(
tmp_path: Path,
) -> None:
"""THE DEFECT THIS REPRODUCES WAS FOUND BY USING THE TOOL, not by reading the code. A function_dossier
reported `line_start: 896` and returned 55 lines of a DIFFERENT function; `line_start`,
`line_end` and `total_lines` were all self-consistent, so nothing in the payload contradicted
it, and the reader went and read the file instead — a miss the tool caused and then concealed.
THE MECHANISM IS NOT STALENESS IN GENERAL. `body_excerpt` reads the LIVE working tree at the
span the INDEX recorded. Same rowid, same identity, correct name, correct file — and text that
has since moved. `body_excerpt`'s own docstring already called quoting another function's
source "the worst possible version of that bug, because a body looks like proof", and guarded
only the re-resolution route to it; this is the other route.
BOTH DIRECTIONS ARE ASSERTED IN ONE TEST so they cannot drift apart. Before the edit the
excerpt must report `anchor_mismatch is False` — a check that fires on an untouched tree is
worse than no check — and after prepending enough lines to push a different function into the
recorded span it must report True. The lines are still returned either way: withholding
evidence is worse than labelling it.
@brief A moved body is disclosed rather than passed off as the function's own.
@version 1
"""
root = tmp_path / "drift"
(root / "src").mkdir(parents=True)
source = root / "src" / "drift.c"
source.write_text(DRIFT_SOURCE, encoding="utf-8")
doxyfile = root / "Doxyfile"
doxyfile.write_text(DOXYFILE, encoding="utf-8")
db = tmp_path / "drift.db"
build_index(output=db, repo_root=root, doxyfile=doxyfile)
fresh = function_dossier(db, "drift_subject", repo_root=root)
assert fresh is not None and fresh.body is not None, "the fixture must produce a body"
assert fresh.body.anchor_mismatch is False, (
f"the tree is untouched, so the excerpt is the function's own — a mismatch here means the "
f"check fires on ordinary code: {fresh.body.lines}"
)
assert any("drift_subject" in line for line in fresh.body.lines), (
"and the excerpt really is anchored at the signature, which is what makes the check work"
)
## THE EDIT. Prepending nine lines pushes `drift_neighbour` into the span recorded for
## `drift_subject`, which is the shape measured in the wild rather than a truncation.
source.write_text("/* nine\n * added\n * lines\n * of\n * new\n * leading\n * comment\n"
" * text\n */\n" + DRIFT_SOURCE, encoding="utf-8") # fmt: skip
moved = function_dossier(db, "drift_subject", repo_root=root)
assert moved is not None and moved.body is not None
assert moved.body.anchor_mismatch is True, (
f"the recorded span no longer holds this function, and saying nothing is what sent a "
f"reader to the file: {moved.body.lines}"
)
assert moved.body.lines, (
"the lines must still be returned — withholding the evidence is worse than labelling it, "
"and a reader may still recognise what they are looking at"
)1 more lines, not shown
Activity · 17 steps
test_a_dossier_reports_the_gates_covering_the_function
None test_gate_coverage_integration.test_a_dossier_reports_the_gates_covering_the_function(Path tmp_path)
Gate coverage survives a real build and keeps its polarity.
tests/integration/test_gate_coverage_integration.py:99
Checks
assert fast_unplaceable == 0, ("every gate in this file was harvested with an extent, so an empty gate list here would " "mean ungated rather than unknown — the count is what separates those two answers" )assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFDEF) in fast, (f"the true branch must report the symbol as required: {sorted(fast)}" )assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFNDEF) not in fast, (f"and must not ALSO report the inverse — that is the node-extent bug: {sorted(fast)}" )assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFNDEF) in slow, (f"the else branch is present when the symbol is NOT set: {sorted(slow)}" )assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFDEF) not in slow, (f"reporting the else branch as gated ON the symbol inverts the variant: {sorted(slow)}" )assert not always, (f"a function outside every conditional must report no preconditions: {sorted(always)}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | measured | |
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-004 | measured | |
| REQ-DDB-CONFIG-005 | measured | |
| REQ-DDB-CONFIG-006 | measured | |
| REQ-DDB-CONFIG-007 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-INDEX-001 | measured | |
| REQ-DDB-INDEX-002 | measured | |
| REQ-DDB-INDEX-003 | measured | |
| REQ-DDB-INDEX-004 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → symbol_provenance |
| REQ-DDB-INDEX-005 | measured | |
| REQ-DDB-INDEX-006 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-INDEX-008 | measured | |
| REQ-DDB-INDEX-009 | measured | |
| REQ-DDB-INDEX-010 | measured | |
| REQ-DDB-INDEX-011 | measured | |
| REQ-DDB-MCP-001 | measured | |
| REQ-DDB-MCP-004 | measured | |
| REQ-DDB-PIPE-001 | measured | |
| REQ-DDB-PIPE-003 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-004 | measured | |
| REQ-DDB-PIPE-005 | measured | |
| REQ-DDB-PIPE-006 | measured | |
| REQ-DDB-PIPE-007 | measured | |
| REQ-DDB-PIPE-008 | measured | |
| REQ-DDB-PIPE-009 | measured | |
| REQ-DDB-PIPE-010 | measured | |
| REQ-DDB-PIPE-011 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language |
| REQ-DDB-PIPE-013 | measured | |
| REQ-DDB-PIPE-014 | measured | |
| REQ-DDB-PIPE-015 | measured | |
| REQ-DDB-QUERY-001 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → connect |
| REQ-DDB-QUERY-002 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → unresolved_inbound_for_rowids |
| REQ-DDB-QUERY-003 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → function_candidates |
| REQ-DDB-QUERY-004 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier |
| REQ-DDB-QUERY-006 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → gates_covering |
| REQ-DDB-QUERY-009 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier |
| REQ-DDB-QUERY-010 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier |
| REQ-DDB-QUERY-011 | measured | |
| REQ-DDB-QUERY-012 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → _macro_dossier |
| REQ-DDB-QUERY-013 | inferred | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → config_defaults_conn |
| REQ-DDB-SCHEMA-001 | measured | |
| REQ-DDB-SCHEMA-002 | measured | |
| REQ-DDB-SCHEMA-003 | measured | |
| REQ-DDB-SCHEMA-004 | measured | |
| REQ-DDB-SCHEMA-005 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-007 | measured | |
| REQ-DDB-SCHEMA-009 | measured | |
| REQ-DDB-SCHEMA-011 | measured | test_a_dossier_reports_the_gates_covering_the_function → _gated_by → function_dossier → _dossier_conn → locks_held_for_rowids |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-013 | measured | |
| REQ-DDB-SCHEMA-014 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 51 lines
def test_a_dossier_reports_the_gates_covering_the_function(tmp_path: Path) -> None:
"""ONE REAL BUILD, THREE FUNCTIONS, TWO-SIDED THROUGHOUT.
`fixture_fast` must be reported as requiring the symbol and NOT as requiring its absence;
`fixture_slow` the other way round; `fixture_always` as neither. A one-sided version of any
of these passes against an implementation that attributes every gate in the file to every
line — which is what storing the conditional's whole extent produces, and it is the natural
thing to write.
NOTE WHAT IS NOT ASSERTED: whether the symbol is actually DEFINED for this build. That is a
different question (`preprocessor`/`predefined` answers it) and conflating them is how "the
text is present" gets read as "the code is compiled in". This field says what the presence
DEPENDS ON, which is the fact a grep cannot supply at any cost.
@brief Gate coverage survives a real build and keeps its polarity.
@version 1
"""
root = tmp_path / "gated"
(root / "src").mkdir(parents=True)
(root / "src" / "fixture.c").write_text(SOURCE, encoding="utf-8")
doxyfile = root / "Doxyfile"
doxyfile.write_text(DOXYFILE, encoding="utf-8")
db = tmp_path / "gates.db"
build_index(output=db, repo_root=root, doxyfile=doxyfile)
fast, fast_unplaceable = _gated_by(db, "fixture_fast")
slow, _ = _gated_by(db, "fixture_slow")
always, _ = _gated_by(db, "fixture_always")
assert fast_unplaceable == 0, (
"every gate in this file was harvested with an extent, so an empty gate list here would "
"mean ungated rather than unknown — the count is what separates those two answers"
)
assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFDEF) in fast, (
f"the true branch must report the symbol as required: {sorted(fast)}"
)
assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFNDEF) not in fast, (
f"and must not ALSO report the inverse — that is the node-extent bug: {sorted(fast)}"
)
assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFNDEF) in slow, (
f"the else branch is present when the symbol is NOT set: {sorted(slow)}"
)
assert ("FIXTURE_FAST_PATH", KCONFIG_GATE_IFDEF) not in slow, (
f"reporting the else branch as gated ON the symbol inverts the variant: {sorted(slow)}"
)
assert not always, (
f"a function outside every conditional must report no preconditions: {sorted(always)}"
)
Activity · 16 steps
test_a_gate_says_whether_this_build_satisfied_it
None test_gate_coverage_integration.test_a_gate_says_whether_this_build_satisfied_it(Path tmp_path)
One build distinguishes a satisfied gate from an unsatisfied one.
tests/integration/test_gate_coverage_integration.py:165
Checks
assert doss is not None, ("the function must be INDEXED even though the build does not satisfy its gates — that is " "gh#11's recovery, and it is what makes 'index the union, label the branches' possible " "without running the preprocessor twice" )assert origins.get("FIXTURE_DECLARED") == GATE_ORIGIN_DECLARED, (f"the build declared this macro, so the gate must say so: {origins}" )assert origins.get("FIXTURE_ABSENT") == GATE_ORIGIN_UNDECLARED, (f"the build did NOT declare this one, and that is the half that says the code is absent " f"from this variant: {origins}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | measured | |
| REQ-DDB-CONFIG-001 | measured | |
| REQ-DDB-CONFIG-004 | measured | |
| REQ-DDB-CONFIG-005 | measured | |
| REQ-DDB-CONFIG-006 | measured | |
| REQ-DDB-CONFIG-007 | measured | |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-INDEX-001 | measured | |
| REQ-DDB-INDEX-002 | measured | |
| REQ-DDB-INDEX-003 | measured | |
| REQ-DDB-INDEX-004 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → symbol_provenance |
| REQ-DDB-INDEX-005 | measured | |
| REQ-DDB-INDEX-006 | measured | |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-INDEX-008 | measured | |
| REQ-DDB-INDEX-009 | measured | |
| REQ-DDB-INDEX-010 | measured | |
| REQ-DDB-INDEX-011 | measured | |
| REQ-DDB-MCP-001 | measured | |
| REQ-DDB-MCP-004 | measured | |
| REQ-DDB-PIPE-001 | measured | |
| REQ-DDB-PIPE-003 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree |
| REQ-DDB-PIPE-004 | measured | |
| REQ-DDB-PIPE-005 | measured | |
| REQ-DDB-PIPE-006 | measured | |
| REQ-DDB-PIPE-007 | measured | |
| REQ-DDB-PIPE-008 | measured | |
| REQ-DDB-PIPE-009 | measured | |
| REQ-DDB-PIPE-010 | measured | |
| REQ-DDB-PIPE-011 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language |
| REQ-DDB-PIPE-013 | measured | |
| REQ-DDB-PIPE-014 | measured | |
| REQ-DDB-PIPE-015 | measured | |
| REQ-DDB-QUERY-001 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → connect |
| REQ-DDB-QUERY-002 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → unresolved_inbound_for_rowids |
| REQ-DDB-QUERY-003 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → function_candidates |
| REQ-DDB-QUERY-004 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier |
| REQ-DDB-QUERY-006 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → gates_covering |
| REQ-DDB-QUERY-009 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier |
| REQ-DDB-QUERY-010 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier |
| REQ-DDB-QUERY-011 | measured | |
| REQ-DDB-QUERY-012 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → _macro_dossier |
| REQ-DDB-QUERY-013 | inferred | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → config_defaults_conn |
| REQ-DDB-SCHEMA-001 | measured | |
| REQ-DDB-SCHEMA-002 | measured | |
| REQ-DDB-SCHEMA-003 | measured | |
| REQ-DDB-SCHEMA-004 | measured | |
| REQ-DDB-SCHEMA-005 | measured | |
| REQ-DDB-SCHEMA-006 | measured | |
| REQ-DDB-SCHEMA-007 | measured | |
| REQ-DDB-SCHEMA-009 | measured | |
| REQ-DDB-SCHEMA-011 | measured | test_a_gate_says_whether_this_build_satisfied_it → function_dossier → _dossier_conn → locks_held_for_rowids |
| REQ-DDB-SCHEMA-012 | measured | |
| REQ-DDB-SCHEMA-013 | measured | |
| REQ-DDB-SCHEMA-014 | measured | |
| REQ-DDB-SCHEMA-015 | measured |
Source · 57 lines
def test_a_gate_says_whether_this_build_satisfied_it(tmp_path: Path) -> None:
"""PLAN ITEM 2.8, AND THE ANSWER TURNED OUT TO BE A COMPOSITION RATHER THAN A NEW LAYER. The
item asked to make `--predefined` ADDITIVE — to LABEL what is on and off instead of deciding
what is indexed — and left open "whether doxygen alone can do this or the tree-sitter path
must supply the excluded branches". The tree-sitter path ALREADY supplies them: gh#11 recovers
a function doxygen never emitted, precisely BECAUSE the preprocessor skipped it. So what was
missing was never the rows; it was the label, and three fields on one row now carry it:
* `macro` — which flag decides this code
* `form` — which way (`ifdef` present-when-set, `ifndef` present-when-unset)
* `origin` — whether THIS BUILD's declared configuration supplies that macro
That triple answers "is it compiled in, and under what flag" from a single row, which is what
both graded questions ask and what `grep` cannot answer at any price.
THE WIRING IS THE THING UNDER TEST, not the vocabulary. `origin` is computed from the
`declared` set that `cli` passes as `preprocessor.macros`; if that argument were ever dropped
or defaulted, every gate would come back `undeclared` and the field would still look
plausible — a whole configuration reported as absent, confidently. This repo has shipped
exactly that shape before (a check that could not read its input reported nothing, which
looked like passing), so the control is that ONE BUILD produces BOTH labels: `FIXTURE_DECLARED`
must read `declared` and `FIXTURE_ABSENT` `undeclared`. A single-label assertion passes
against a hardcoded constant.
@brief One build distinguishes a satisfied gate from an unsatisfied one.
@version 1
"""
root = tmp_path / "twoflag"
(root / "src").mkdir(parents=True)
(root / "src" / "twoflag.c").write_text(TWO_FLAG_SOURCE, encoding="utf-8")
doxyfile = root / "Doxyfile"
doxyfile.write_text(DOXYFILE, encoding="utf-8")
db = tmp_path / "twoflag.db"
build_index(
output=db,
repo_root=root,
doxyfile=doxyfile,
options={"predefined": ["FIXTURE_DECLARED"]},
)
doss = function_dossier(db, "fixture_two_flags")
assert doss is not None, (
"the function must be INDEXED even though the build does not satisfy its gates — that is "
"gh#11's recovery, and it is what makes 'index the union, label the branches' possible "
"without running the preprocessor twice"
)
origins = {gate.macro: gate.origin for gate in doss.gated_by}
assert origins.get("FIXTURE_DECLARED") == GATE_ORIGIN_DECLARED, (
f"the build declared this macro, so the gate must say so: {origins}"
)
assert origins.get("FIXTURE_ABSENT") == GATE_ORIGIN_UNDECLARED, (
f"the build did NOT declare this one, and that is the half that says the code is absent "
f"from this variant: {origins}"
)