test_lock_site_detects_mutex_lock_binding¶
Tests › tests/test_rust_ast.py
What this test is for
Why it exists
The test says nothing about why.
Given
tree, src = _parse( "struct Counter { mutex: std::sync::Mutex<i32> }\n" "impl Counter {\n" " fn bump(&self) {\n" " let mut g = self.mutex.lock().unwrap();\n" " *g += 1;\n" " }\n" "}\n" )
When
patterns = {p.name: p for p in load_lock_patterns(None)}sites = _walk_lock_sites(tree, src, patterns)name, operand, scope, line, end_line, form, kind, mode, role, confidence, calls = sites[0]
Then
- ✓ len(sites) equals 1
- ✓ name equals "lock"
- ✓ operand equals "self.mutex"
- ✓ scope equals "class:Counter"
- ✓ form equals "raii"
- ✓ kind equals "mutex"
- ✓ mode equals "exclusive"
- ✓ confidence equals "high"
tests/test_rust_ast.py:105 · its file's page
What it checks (8)
assert len(sites) == 1observes_walk_lock_sitesviasitesassert name == "lock"not attributedassert operand == "self.mutex"not attributedassert scope == "class:Counter"not attributedassert form == "raii"not attributedassert kind == "mutex"not attributedassert mode == "exclusive"not attributedassert confidence == "high"not attributed
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 3 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-PIPE-003 measured
- REQ-DDB-SCHEMA-011 measured
- REQ-DDB-SCHEMA-012 measured