feat(exec): add path prepend config

This commit is contained in:
chengyongru
2026-06-10 18:09:57 +08:00
committed by Xubin Ren
parent 8c30dc5a57
commit dadb35af49
11 changed files with 169 additions and 5 deletions
+22
View File
@@ -45,6 +45,28 @@ async def test_exec_path_append_preserves_system_path():
assert "Exit code: 0" in result
@_UNIX_ONLY
@pytest.mark.asyncio
async def test_exec_path_prepend_takes_lookup_precedence(tmp_path):
"""pathPrepend should win over pathAppend for executable lookup."""
preferred = tmp_path / "preferred"
fallback = tmp_path / "fallback"
preferred.mkdir()
fallback.mkdir()
preferred_tool = preferred / "pathprobe"
fallback_tool = fallback / "pathprobe"
preferred_tool.write_text("#!/bin/sh\necho preferred\n", encoding="utf-8")
fallback_tool.write_text("#!/bin/sh\necho fallback\n", encoding="utf-8")
preferred_tool.chmod(0o755)
fallback_tool.chmod(0o755)
tool = ExecTool(path_prepend=str(preferred), path_append=str(fallback))
result = await tool.execute(command="pathprobe")
assert "preferred" in result
assert "fallback" not in result
@_UNIX_ONLY
@pytest.mark.asyncio
async def test_exec_allowed_env_keys_passthrough(monkeypatch):