From b7a4ef20ed560d91c5aaf8ed5291886dd7409311 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Mon, 26 Oct 2026 22:19:45 +0000 Subject: [PATCH] test: keep the slack team-id spawn tests off real Windows process calls On Windows, launch() wraps the spawn factory in platform_compat.create_windows_cleanup_owned_process, which hands it a cleanup owner. create_subprocess_limited then calls native CreateProcess through _create_windows_subprocess_owned instead of the mocked asyncio.create_subprocess_exec, and the synthetic /usr/bin/kiro-cli is not found (WinError 2). All six TestSpawnEnv tests failed on the Windows shard. Pass the factory straight through, as test_xdist_auto_cap.py already does for the same seam, and stub finish_suspended_spawn, which on Windows would resume every thread of the mocked pid 12345 on the host. The behaviour under test (the env the child is handed) is not POSIX-only, so the tests keep running on Windows. --- test/test_slack_team_id_env.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_slack_team_id_env.py b/test/test_slack_team_id_env.py index 68f0438b97c3..6c84e98538f4 100644 --- a/test/test_slack_team_id_env.py +++ b/test/test_slack_team_id_env.py @@ -59,6 +59,19 @@ def _clean_team_registry(_floor_monkeypatch: pytest.MonkeyPatch): team_ids._reset_for_tests() +async def _spawn_without_windows_cleanup_capture(factory): + """Run the spawn factory the way the POSIX branch of the seam does. + + On Windows the spawn goes through + ``platform_compat.create_windows_cleanup_owned_process``, which hands the factory + a cleanup owner; ``create_subprocess_limited`` then calls native CreateProcess + directly, past the mocked ``asyncio.create_subprocess_exec``, and fails on the + synthetic binary. A mocked spawn owns no real child to pin, and these tests ask + only what environment the spawn is handed. + """ + return await factory() + + async def _spawn_env(client: AcpClient, *, claude: bool = False) -> dict[str, str]: """Spawn *client* against a mocked process and return the child env.""" if claude: @@ -80,6 +93,13 @@ async def _spawn_env(client: AcpClient, *, claude: bool = False) -> dict[str, st ), patch("kiro_crew.acp.client.wrap_argv", return_value=(argv, None)), patch("asyncio.create_subprocess_exec", new_callable=AsyncMock) as mock_exec, + patch( + "kiro_crew.platform_compat.create_windows_cleanup_owned_process", + side_effect=_spawn_without_windows_cleanup_capture, + ), + # On Windows this applies a Job ceiling and resumes every thread of the + # pid it is handed; the mocked pid is not a child, so nothing may act on it. + patch("kiro_crew.acp.client.finish_suspended_spawn"), patch("kiro_crew.session._track_pid"), patch("kiro_crew.session._track_session_pid"), ):