Test that the gathering claude starts with the release's tools on its PATH
CI / tests (pull_request) Successful in 7m0s
CI / tests (pull_request) Successful in 7m0s
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -9,7 +10,8 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
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 failure import Failure
|
||||||
from task_bench.figures.gather import gather, PROMPT
|
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")
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user