test_a_contended_build_gives_up_and_proceeds

Tests › tests/test_buildlock.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE LOAD-BEARING TEST, because this is the failure this lock could introduce. A holder that outlasts the wait must leave the second process free to BUILD — reporting `held=False` — not waiting on it. The caller treats False as "proceed", so a lock that never returned would be a hang, and hangs are what the three releases before this were about.

Given

  1. db = tmp_path / "clew.db"
  2. acquired = multiprocessing.Value("i", 0)
2 more
  1. child = multiprocessing.Process(target=_hold, args=(str(db), acquired, 5.0))
  2. child.start()
→

When

  1. try: for _ in range(100): # wait for the child to actually hold it if acquired.value: break time.sleep(0.05) assert acquired.value == 1, "the child never acquired the lock — test would be vacuous" started = time.monotonic() with build_lock(db, wait_seconds=0.5) as held: elapsed = time.monotonic() - started assert held is False, ( "the lock was reported held while a child process held it — that would let two " "builds run believing each was exclusive" ) assert elapsed < 4.0, ( f"waited {elapsed:.1f}s despite a 0.5s bound; an unbounded wait here is a hang" ) finally: child.join(timeout=10) if child.is_alive(): # pragma: no cover child.kill() child.join()
→

Then

  1. —

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 2 of 142 steps

… 60 earlier steps

thread startthread startthread startthread startclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/server.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyclew/mcp_server/state.pyother filesother filesother filesother filestry (line 3260)try_first_build_worker61. _run_build_walked → captured_output61captured_output62. _run_build_walked → build_lock62build_lock63. build_lock → _os_lock63_os_lock▶ test enters64. _os_lock → lock_path64lock_path65. _run_build_walked → db_status65db_status66. db_status → _options_meta66_options_meta

… 76 later steps

tests/test_buildlock.py:67 · its file's page

What it checks (3)

  1. assert acquired.value == 1, "the child never acquired the lock — test would be vacuous" not attributed
  2. assert held is False, ( "the lock was reported held while a child process held it — that would let two " "builds run believing each was exclusive" ) not attributed
  3. assert elapsed < 4.0, ( f"waited {elapsed:.1f}s despite a 0.5s bound; an unbounded wait here is a hang" ) 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_a_contended_build_gives_up_and_proceeds→build_lock

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_a_contended_build_gives_up_and_proceeds · 3 checksbuild_lockREQ-DDB-INDEX-002 · measured
Also reaches 1 requirement

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