SPB Git

spb/wp29_uqo

Public
1.1 KB · 15 lines python
1import os, sys, subprocess, tempfile2sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "src"))3from pgar.launcher import build_command, remote_shell_line45def test_prompt_file_reaches_client_as_one_argument():6    """Simulate the remote shell line locally with a fake `claude` that prints its argv, and check the whole prompt arrives as one argument."""7    d = tempfile.mkdtemp(); pf = os.path.join(d, "prompt.txt"); open(pf, "w").write("Begin now. The task is in TASK.md; stop when done.\n")8    fake = os.path.join(d, "claude"); open(fake, "w").write("#!/bin/sh\nfor a in \"$@\"; do printf '%s\\n' \"$a\"; done\n"); os.chmod(fake, 0o755)9    open(os.path.join(d, ".env"), "w").write("X=1\n")10    argv = build_command(d, d, pf, os.path.join(d, "sys.md"), "m", "sid", 1.0, 5)11    line = remote_shell_line(d, argv, env_file=os.path.join(d, ".env")).replace("export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH", f"export PATH={d}:$PATH")12    out = subprocess.run(["bash", "-c", line], capture_output=True, text=True).stdout.splitlines()13    i = out.index("-p") + 114    assert out[i].startswith("Begin now. The task is in TASK.md"), out[:6]15
Files · 452964ee0fbbaa40fbbed2c87a54ca798ffd6a85
Menu

Theme