Name each file of the setup as the setup's, and a config's as setup:<path>
CI / tests (pull_request) Successful in 4m42s
CI / tests (pull_request) Successful in 4m42s
This commit is contained in:
@@ -14,7 +14,7 @@ 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
|
||||
from task_bench.figures.gather import gather, once_ready, PROMPT
|
||||
from test_env import isolated_env
|
||||
from task_bench import main
|
||||
|
||||
@@ -69,6 +69,12 @@ class GatherTest(unittest.TestCase):
|
||||
self.assertEqual((self.calls[0][0][2], self.calls[0][1], self.calls[0][2].endswith("\n\nworktree's\n")), ("claude-opus-5-5", str(worktree), True))
|
||||
self.assertEqual((bench.exists(), self.bench.exists()), (False, True))
|
||||
|
||||
def test_the_claude_starts_only_once_the_loops_claude_home_is_ready_and_a_home_that_is_not_keeps_the_folder(self):
|
||||
found = gather(self.env, self.home, once_ready(lambda: "nobody is signed in to the loop's Claude home", self.claude))
|
||||
self.assertEqual((found.reason if isinstance(found, Failure) else found, self.calls), (f"nobody is signed in to the loop's Claude home\nThe digest stays in {self.bench} until the next bench: run `task-bench gather` again.", []))
|
||||
self.assertNotIsInstance(gather(self.env, self.home, once_ready(lambda: None, self.claude)), Failure)
|
||||
self.assertEqual(len(self.calls), 1)
|
||||
|
||||
def test_refuses_without_a_digest_and_starts_no_claude(self):
|
||||
(self.bench / "digest.md").unlink()
|
||||
found = gather(self.env, self.home, self.claude)
|
||||
@@ -143,15 +149,23 @@ class GatherTest(unittest.TestCase):
|
||||
|
||||
|
||||
class RunClaude(unittest.TestCase):
|
||||
def test_runs_claude_in_the_folder_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
|
||||
def test_runs_claude_in_the_loops_claude_home_once_it_is_built_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.write_text("""#!/bin/sh
|
||||
case "$*" in
|
||||
"auth status") echo '{"loggedIn": true}' ;;
|
||||
plugin*) ;;
|
||||
*) echo "$PWD $* $(cat) $PATH $CLAUDE_CONFIG_DIR" ;;
|
||||
esac
|
||||
""")
|
||||
claude.chmod(0o755)
|
||||
# A process of its own, so the test changes no PATH but that process's.
|
||||
# A process of its own, so the test changes no PATH and no home 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)
|
||||
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"HOME": folder, "PATH": f"{folder}:/usr/bin:/bin"}, text=True)
|
||||
home = pathlib.Path(folder, ".local/share/build-release/claude-home")
|
||||
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin {home}\n", done.stderr)
|
||||
self.assertTrue((home / "CLAUDE.md").is_symlink())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user