fix(tools): preserve PATH for argument-vector commands

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-30 13:09:30 +08:00
1 parent 99ba062a97
commit 54d85059a5
2 files changed
+29 -2

No files matched your search

+24
View File
@@ -6,6 +6,7 @@ platform-specific binaries (all subprocess calls are mocked).
"""
import asyncio
import os
import shutil
import sys
from unittest.mock import AsyncMock, MagicMock, patch
@@ -103,6 +104,29 @@ class TestBuildEnvWindows:
assert env["SYSTEMROOT"] == r"D:\Windows"
# ---------------------------------------------------------------------------
# argument-vector PATH
# ---------------------------------------------------------------------------
class TestArgumentVectorPath:
def test_uses_parent_path_for_executable_lookup(self):
parent_path = os.pathsep.join(("parent-bin", "system-bin"))
with (
patch("nanobot.agent.tools.shell._IS_WINDOWS", False),
patch.dict(
"os.environ",
{"PATH": parent_path, "NANOBOT_SECRET_TOKEN": "super-secret-value"},
clear=True,
),
):
prepared = ExecTool()._prepare_command(["rg", "--version"])
assert not isinstance(prepared, str)
assert prepared.env["PATH"] == parent_path
assert "NANOBOT_SECRET_TOKEN" not in prepared.env
# ---------------------------------------------------------------------------
# _spawn
# ---------------------------------------------------------------------------