test_lambda_thread_spawns.py¶
tests/test_lambda_thread_spawns.py
A thread that exists in the source and in no index row.
test_a_lambda_bodied_spawn_is_harvested
None test_lambda_thread_spawns.test_a_lambda_bodied_spawn_is_harvested()
Every lambda-bodied spawn must be harvested, not dropped.
tests/test_lambda_thread_spawns.py:107
Checks
assert len(sites) == 5, (f"expected 5 spawn sites (1 named + 4 lambda-bodied), got {len(sites)}: " f"{[s[0] for s in sites]}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_a_lambda_bodied_spawn_is_harvested → _walk_spawn_sites → is_python_tree |
| REQ-DDB-SCHEMA-001 | measured | test_a_lambda_bodied_spawn_is_harvested → load_thread_patterns |
| REQ-DDB-SCHEMA-012 | inferred | test_a_lambda_bodied_spawn_is_harvested → load_thread_patterns → declaration_origin |
Source · 19 lines
def test_a_lambda_bodied_spawn_is_harvested() -> None:
"""FIVE SITES IN THIS FIXTURE: one named entry and four lambdas, three assigned and one
detached temporary. Before the fix only the named one survived.
@brief All five spawn sites are seen.
@return None.
@version 1
"""
patterns = patterns_by_name(load_thread_patterns(None))
tree, src = _parse(_LAMBDA_FORMS)
sites = _walk_spawn_sites(tree, src, patterns)
assert len(sites) == 5, (
f"expected 5 spawn sites (1 named + 4 lambda-bodied), got {len(sites)}: "
f"{[s[0] for s in sites]}"
)
Activity · 4 steps
test_the_named_entry_control_still_resolves
None test_lambda_thread_spawns.test_the_named_entry_control_still_resolves()
The named-entry control must still resolve to its entry function.
tests/test_lambda_thread_spawns.py:130
Checks
assert "monitor_loop" in entries, f"the named entry stopped resolving: {entries}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_the_named_entry_control_still_resolves → _walk_spawn_sites → is_python_tree |
| REQ-DDB-SCHEMA-001 | measured | test_the_named_entry_control_still_resolves → load_thread_patterns |
| REQ-DDB-SCHEMA-012 | inferred | test_the_named_entry_control_still_resolves → load_thread_patterns → declaration_origin |
Source · 17 lines
def test_the_named_entry_control_still_resolves() -> None:
"""THE TWO-SIDED ASSERTION. Recording unnameable entries must not cost the nameable ones, and
a test that only counted rows would not notice if it had.
@brief A named entry keeps its entry name.
@return None.
@version 1
"""
patterns = patterns_by_name(load_thread_patterns(None))
tree, src = _parse(_LAMBDA_FORMS)
sites = _walk_spawn_sites(tree, src, patterns)
entries = [s[1] for s in sites]
assert "monitor_loop" in entries, f"the named entry stopped resolving: {entries}"
Activity · 5 steps
test_unnamed_spawns_get_distinct_names
None test_lambda_thread_spawns.test_unnamed_spawns_get_distinct_names()
Unnamed spawns must carry distinct names, or they collapse to one row.
tests/test_lambda_thread_spawns.py:151
Checks
assert len(set(names)) == len(names), f"spawn names collide and would collapse rows: {names}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-003 | measured | test_unnamed_spawns_get_distinct_names → _walk_spawn_sites → is_python_tree |
| REQ-DDB-SCHEMA-001 | measured | test_unnamed_spawns_get_distinct_names → load_thread_patterns |
| REQ-DDB-SCHEMA-012 | inferred | test_unnamed_spawns_get_distinct_names → load_thread_patterns → declaration_origin |
Source · 19 lines
def test_unnamed_spawns_get_distinct_names() -> None:
"""**THE FIX THAT LOOKS LIKE IT WORKED AND UNDERCOUNTS BY THREE.** `threads` is
UNIQUE(name, entry_memberdef_rowid, kind). With a NULL entry, four lambdas sharing one
placeholder name collapse into a single row, so the harvester would report 2 threads where
the source has 5 — and every count downstream would be wrong while the bug report said fixed.
The assignment target is what distinguishes them: `poller_`, `poller`, `observer`. The
detached temporary has no target and must still differ from the others.
@brief Unnamed spawns do not collide.
@return None.
@version 1
"""
patterns = patterns_by_name(load_thread_patterns(None))
tree, src = _parse(_LAMBDA_FORMS)
names = [s[0] for s in _walk_spawn_sites(tree, src, patterns)]
assert len(set(names)) == len(names), f"spawn names collide and would collapse rows: {names}"1 more lines, not shown