test_lock_site_detects_mutex_lock_binding

Tests › tests/test_rust_ast.py

passed Passed in the packaged run.

What this test is for

Why it exists

The test says nothing about why.

Given

  1. 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

  1. patterns = {p.name: p for p in load_lock_patterns(None)}
  2. sites = _walk_lock_sites(tree, src, patterns)
  3. name, operand, scope, line, end_line, form, kind, mode, role, confidence, calls = sites[0]
→

Then

  1. ✓ len(sites) equals 1
  2. ✓ name equals "lock"
  3. ✓ operand equals "self.mutex"
  4. ✓ scope equals "class:Counter"
  5. ✓ form equals "raii"
  6. ✓ kind equals "mutex"
  7. ✓ mode equals "exclusive"
  8. ✓ confidence equals "high"

tests/test_rust_ast.py:105 · its file's page

What it checks (8)

  1. assert len(sites) == 1 observes _walk_lock_sites via sites
  2. assert name == "lock" not attributed
  3. assert operand == "self.mutex" not attributed
  4. assert scope == "class:Counter" not attributed
  5. assert form == "raii" not attributed
  6. assert kind == "mutex" not attributed
  7. assert mode == "exclusive" not attributed
  8. assert 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

test_lock_site_detects_mutex_lock_binding→_parse→load_lock_patterns→_walk_lock_sites

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.

test_lock_site_detects_mutex_lock_binding · 8 checks_walk_lock_sites… 3 calls …enclosingREQ-DDB-PIPE-003 · measuredload_lock_patternsREQ-DDB-SCHEMA-011 · measuredload_lock_patternsdeclaration_originREQ-DDB-SCHEMA-012 · measured
Also reaches 3 requirements

Its run touches their code; that is reach, not proof.