The launchd service runs with PATH=/usr/bin:/bin:/usr/sbin:/sbin; tmux split-window gives the new pane the caller's PATH, so 'exec lf' failed and the pane closed at once. install.sh now records its own PATH in the plist EnvironmentVariables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.1 KiB
Python
52 lines
2.1 KiB
Python
import os
|
|
import plistlib
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
|
|
sys.path.insert(0, os.path.join(ROOT, "files"))
|
|
import claude_agents # noqa: E402
|
|
import launchagent # noqa: E402
|
|
|
|
SCRIPT = os.path.join(ROOT, "files", "launchagent.py")
|
|
|
|
|
|
class Plist(unittest.TestCase):
|
|
def test_label_matches_server(self):
|
|
self.assertEqual(launchagent.LABEL, "com.andrey.claude-agents")
|
|
self.assertEqual(launchagent.LABEL, claude_agents.SERVICE_LABEL)
|
|
|
|
def test_plist_shape(self):
|
|
self.assertEqual(
|
|
launchagent.plist("/opt/homebrew/bin/python3", "/x/claude_agents.py", "/l/panel.log",
|
|
"/opt/homebrew/bin:/usr/bin:/bin"),
|
|
{"Label": "com.andrey.claude-agents",
|
|
"ProgramArguments": ["/opt/homebrew/bin/python3", "/x/claude_agents.py", "--headless"],
|
|
"EnvironmentVariables": {"PATH": "/opt/homebrew/bin:/usr/bin:/bin"},
|
|
"RunAtLoad": True, "KeepAlive": True,
|
|
"StandardOutPath": "/l/panel.log", "StandardErrorPath": "/l/panel.log"})
|
|
|
|
|
|
class Cli(unittest.TestCase):
|
|
def test_cli_writes_plist_with_spaces(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
target = f"{tmp}/LaunchAgents/a.plist"
|
|
args = ("/usr/bin/python3", f"{tmp}/Application Support/claude_agents.py",
|
|
f"{tmp}/Logs/claude-agents/panel.log", "/opt/homebrew/bin:/usr/bin:/bin")
|
|
r = subprocess.run([sys.executable, SCRIPT, "write", target, *args],
|
|
capture_output=True, text=True)
|
|
self.assertEqual(r.returncode, 0, r.stderr)
|
|
with open(target, "rb") as f:
|
|
self.assertEqual(plistlib.load(f), launchagent.plist(*args))
|
|
self.assertTrue(os.path.isdir(f"{tmp}/Logs/claude-agents"))
|
|
|
|
def test_cli_bad_args(self):
|
|
r = subprocess.run([sys.executable, SCRIPT, "write"], capture_output=True, text=True)
|
|
self.assertEqual(r.returncode, 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|