From f82ecd937c187acfa60b662b772e95d9c69bf868 Mon Sep 17 00:00:00 2001 From: "Bingxi Zhao (Frank)" <13051345080@163.com> Date: Wed, 2 Dec 2026 11:37:45 +0800 Subject: [PATCH] test: scope POSIX-only sandbox fallback and file-mode checks --- tests/services/cli_apps/test_state_and_paths.py | 7 ++++++- tests/services/mcp/test_oauth.py | 2 ++ tests/services/sandbox/test_argv_exec.py | 14 +++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/services/cli_apps/test_state_and_paths.py b/tests/services/cli_apps/test_state_and_paths.py index 5169611f2..f1c745fae 100644 --- a/tests/services/cli_apps/test_state_and_paths.py +++ b/tests/services/cli_apps/test_state_and_paths.py @@ -10,6 +10,7 @@ filename. from __future__ import annotations from pathlib import Path +import sys import pytest @@ -82,6 +83,7 @@ def test_a_preferences_file_cannot_be_addressed_outside_its_directory(owner: str prefs_path(owner) +@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file modes") def test_the_tree_is_created_owner_only(cli_app_roots: Path) -> None: root = ensure_root() assert root.is_dir() @@ -99,7 +101,10 @@ def test_an_executable_path_cannot_escape_the_app_directory(entry_point: str) -> def test_an_executable_resolves_inside_its_own_app_directory() -> None: path = executable_path("demo", AppRuntime.PYTHON, "cli-anything-demo") assert path.is_relative_to(app_dir("demo")) - assert path.name == "cli-anything-demo" + # A Windows Python venv writes the console script as ``.exe``. + assert path.name == ( + "cli-anything-demo.exe" if sys.platform == "win32" else "cli-anything-demo" + ) def test_each_app_gets_its_own_environment() -> None: diff --git a/tests/services/mcp/test_oauth.py b/tests/services/mcp/test_oauth.py index 3b6acee95..3f4cc66a6 100644 --- a/tests/services/mcp/test_oauth.py +++ b/tests/services/mcp/test_oauth.py @@ -11,6 +11,7 @@ import asyncio import json from pathlib import Path import stat +import sys from urllib.parse import parse_qs, urlsplit import pytest @@ -252,6 +253,7 @@ def test_the_store_is_outside_every_sandbox_mounted_tree(roots: Path) -> None: assert not path.is_relative_to(roots / "user" / "workspace") +@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file modes") def test_the_store_file_is_owner_only(roots: Path) -> None: asyncio.run(_store("u_ada", "notion")) path = oauth._store_path("u_ada", "notion") diff --git a/tests/services/sandbox/test_argv_exec.py b/tests/services/sandbox/test_argv_exec.py index 6cb888102..8e4fa2350 100644 --- a/tests/services/sandbox/test_argv_exec.py +++ b/tests/services/sandbox/test_argv_exec.py @@ -143,10 +143,22 @@ def test_the_local_backend_passes_a_hostile_argument_through_untouched(argument: assert result.stdout == argument +@pytest.mark.skipif( + sys.platform == "win32", + reason=( + "the compatibility string is shlex-joined for the Linux runner image; " + "PowerShell cannot parse POSIX quoting and argv is what Windows runs" + ), +) @pytest.mark.parametrize("argument", HOSTILE_ARGS) def test_the_shell_fallback_is_quoted_well_enough_to_be_equivalent(argument: str) -> None: """The compatibility path has to be *correct*, not merely present: on an old - runner image this string is what actually executes.""" + runner image this string is what actually executes. + + That runner image is Linux-only. Windows has no pre-``argv`` runner: the + local backend execs the vector itself, and a POSIX-quoted string handed to + PowerShell is a parse error rather than a different execution. + """ request = ExecRequest.of_argv( ["/usr/bin/env", "python3", "-c", "import sys; print(sys.argv[1], end='')", argument] )