From 8332631b7e53561ab8f7450bbd57743e2355cc61 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 23 Nov 2026 17:05:56 +0000 Subject: [PATCH] test(code-graph): wait for the index helper before the temp dir is removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/test_code_graph.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_code_graph.py b/tests/test_code_graph.py index 8a789b1..c27995b 100644 --- a/tests/test_code_graph.py +++ b/tests/test_code_graph.py @@ -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"))