ci: add Windows and Python 3.14 support

This commit is contained in:
Jiajun Xie
2026-04-17 16:11:37 +08:00
committed by Xubin Ren
parent ce5272c153
commit 3db2eb66e4
7 changed files with 92 additions and 24 deletions
+7 -10
View File
@@ -1,4 +1,3 @@
import shlex
import subprocess
import sys
from typing import Any
@@ -545,18 +544,16 @@ async def test_exec_always_returns_exit_code() -> None:
assert "hello" in result
async def test_exec_head_tail_truncation() -> None:
async def test_exec_head_tail_truncation(tmp_path) -> None:
"""Long output should preserve both head and tail."""
tool = ExecTool()
# Generate output that exceeds _MAX_OUTPUT (10_000 chars)
# Use current interpreter (PATH may not have `python`). ExecTool uses
# create_subprocess_shell: POSIX needs shlex.quote; Windows uses cmd.exe
# rules, so list2cmdline is appropriate there.
script = "print('A' * 6000 + '\\n' + 'B' * 6000)"
if sys.platform == "win32":
command = subprocess.list2cmdline([sys.executable, "-c", script])
else:
command = f"{shlex.quote(sys.executable)} -c {shlex.quote(script)}"
# Use a temp script file to avoid Windows command line quote parsing issues
script_file = tmp_path / "gen_output.py"
script_file.write_text("print('A' * 6000 + chr(10) + 'B' * 6000)", encoding="utf-8")
# On Windows, cmd.exe handles quotes differently. Use the path directly
# without additional quotes since the temp path shouldn't have spaces.
command = f"{sys.executable} {script_file}"
result = await tool.execute(command=command)
assert "chars truncated" in result
# Head portion should start with As