Put the release's tools on PATH for every claude the loop starts, and name them bare in the prose #794

Merged
lilleman merged 13 commits from item-481 into main 2026-12-03 15:18:57 +01:00
Showing only changes of commit f45883f682 - Show all commits
+15 -1
View File
@@ -2,6 +2,7 @@
import contextlib
import io
import json
import os
import pathlib
import shutil
import subprocess
@@ -9,7 +10,8 @@ import sys
import tempfile
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
BIN = pathlib.Path(__file__).resolve().parents[2]
sys.path.insert(0, str(BIN))
from failure import Failure
from task_bench.figures.gather import gather, PROMPT
@@ -140,5 +142,17 @@ class GatherTest(unittest.TestCase):
self.assertEqual(errors.getvalue(), f"{self.bench} holds no digest: run task-bench in this checkout first.\n")
class RunClaude(unittest.TestCase):
def test_runs_claude_in_the_folder_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
with tempfile.TemporaryDirectory() as folder:
claude = pathlib.Path(folder, "claude")
claude.write_text('#!/bin/sh\necho "$PWD $* $(cat) $PATH"\n')
claude.chmod(0o755)
# A process of its own, so the test changes no PATH but that process's.
call = f"import sys; sys.path.insert(0, {str(BIN)!r}); from task_bench.figures.gather import run_claude; print(run_claude(['-p'], {folder!r}, 'asked').stdout, end='')"
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"PATH": f"{folder}:/usr/bin:/bin"}, text=True)
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin\n", done.stderr)
if __name__ == "__main__":
unittest.main()