test(code-graph): wait for the index helper before the temp dir is removed
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s

The last cleanup touched the release file and TemporaryDirectory.cleanup
ran right after it. The released index helper then wrote
state/inflight.json through settle() while rmtree walked the state dir,
so make test failed with OSError 39 Directory not empty. The cleanup now
reads the helper pids under the same lock, releases them and waits until
they have exited.

🎯 Fix: 88 %
💥 Break: 1 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ⛔ fix 88 % < 90

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-23 17:47:35 +00:00
1 parent bf1e482f8b
commit 8332631b7e
1 file changed
+8 -1
+8 -1
View File
@@ -136,7 +136,7 @@ class CodeGraphCase(unittest.TestCase):
self.addCleanup(tmp.cleanup)
self.tmp = Path(tmp.name).resolve()
self.release = self.tmp / "release"
self.addCleanup(self.release.touch)
self.addCleanup(self._release)
self.cache = self.tmp / "cache"
self.cache.mkdir()
self.state = self.tmp / "state"
@@ -232,6 +232,13 @@ class CodeGraphCase(unittest.TestCase):
path = self.state / "inflight.json"
return json.loads(path.read_text(encoding="utf-8") or "{}") if path.is_file() else {}
def _release(self) -> None:
graph = load_graph()
with graph.locked_json(self.state / "inflight.json") as inflight:
helpers = [entry.get("pid") for entry in inflight.values() if isinstance(entry, dict)]
self.release.touch()
wait_for(lambda: not any(graph.alive(pid) for pid in helpers), 15)
def _age_deferred(self, session: str) -> None:
path = self.state / "sessions" / f"{session}.json"
data = json.loads(path.read_text(encoding="utf-8"))