test(issue31): keep every claude tmp root candidate inside the test

The adapter's fixed /tmp fallback is now a module constant. The new tests
point it, TMPDIR, TMP and TEMP at the test's own dirs, in the test process
and (through a sitecustomize on PYTHONPATH) in every python a test starts,
so no test lists the real /tmp/claude-<uid> any more (Mac review, PR #59).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-16 03:16:36 +00:00
1 parent 6f4f40a4ad
commit 26fb1c4130
2 files changed
+40 -5

No files matched your search

@@ -22,6 +22,10 @@ def _projects_dirs(ctx: DiscoveryContext) -> list:
return dirs
# Node's os.tmpdir() when no TMPDIR/TMP/TEMP is set; tests point it elsewhere.
_SYSTEM_TMP = "/tmp"
def _tmp_roots() -> list:
"""The per-uid temp roots claude may have used: ${CLAUDE_CODE_TMPDIR:-
os.tmpdir()}/claude-<uid>. A sandboxed tool shell sets CLAUDE_CODE_TMPDIR
@@ -36,9 +40,9 @@ def _tmp_roots() -> list:
cands.append(override)
# Node's os.tmpdir() on POSIX, not tempfile.gettempdir() (which probes
# writability and falls back to the cwd).
tmp = os.environ.get("TMPDIR") or os.environ.get("TMP") or os.environ.get("TEMP") or "/tmp"
tmp = os.environ.get("TMPDIR") or os.environ.get("TMP") or os.environ.get("TEMP") or _SYSTEM_TMP
cands.append(os.path.join(tmp.rstrip("/") or "/", name))
cands.append(os.path.join("/tmp", name))
cands.append(os.path.join(_SYSTEM_TMP, name))
roots, seen = [], set()
for c in cands:
real = os.path.realpath(c)