fix(exec): stabilize Windows shell tests

This commit is contained in:
Xubin Ren 2026-05-21 16:06:52 +08:00
parent ccbc0bb6e3
commit 835bab5f5a
2 changed files with 6 additions and 2 deletions

View File

@ -414,7 +414,8 @@ class ExecTool(Tool):
) )
shell_program = shell_program or shutil.which("bash") or "/bin/bash" shell_program = shell_program or shutil.which("bash") or "/bin/bash"
args = [shell_program] args = [shell_program]
if login and Path(shell_program).name in {"bash", "zsh"}: shell_name = Path(shell_program).name.lower()
if login and shell_name in {"bash", "bash.exe", "zsh", "zsh.exe"}:
args.append("-l") args.append("-l")
args.extend(["-c", command]) args.extend(["-c", command])
return await asyncio.create_subprocess_exec( return await asyncio.create_subprocess_exec(

View File

@ -37,7 +37,10 @@ def test_exec_keeps_one_shot_behavior_without_yield_time_ms(tmp_path):
def test_exec_accepts_command_aliases(tmp_path): def test_exec_accepts_command_aliases(tmp_path):
async def run() -> str: async def run() -> str:
tool = ExecTool(working_dir="/") tool = ExecTool(working_dir="/")
return await tool.execute(cmd="pwd", workdir=str(tmp_path)) return await tool.execute(
cmd=_python_command("import os; print(os.getcwd())"),
workdir=str(tmp_path),
)
result = asyncio.run(run()) result = asyncio.run(run())