Skip to content

Commit b7cc0df

Browse files
committed
Consolidate stdio tests: in-process logic tests, minimal real-process set
The stdio client's logic — framing, parse errors, the shutdown escalation decisions — is now tested in process against a fake process injected through the spawn seam, and only the properties that are OS behaviour keep real subprocesses. The in-process tests include regressions for the shutdown bugs fixed in the previous commit: cancellation must still run the full shutdown, tree kill must reach children after the leader has exited, writes racing server death must surface clean closure, exiting with a server message still undelivered must be a clean exit, and a server exiting on stdin close must never be terminated. Each was verified to fail against the previous implementation. The real-process set shrinks to: one consolidated tree-kill test driven through the public stdio_client (a parent that exits instantly on SIGTERM, a child, and a grandchild — pinning group inheritance, atomic group kill, and dead-leader robustness in one spawn), the SIGTERM-ignoring SIGKILL escalation test, a dead-group no-op test, and exec-failure ENOENT. Grace and kill timeouts are shortened via monkeypatch in the real tests: the escalation decision is pinned in process against a shortened grace, the SIGTERM-then-SIGKILL escalation itself is exercised only by the real escalation test, and the production constants' values are deliberately unpinned. The stdio surface drops from ~11s to ~3.5s. Deleted as subsumed or broken: - The two tee-based tests: the interaction suite's subprocess e2e pins the real-pipe round trip with a real server, and tee could never deterministically exercise the chunk-reassembly buffer that the new in-process framing test pins (real pipes deliver short messages as whole lines). - test_stdio_client_bad_path: its script only "failed" because non-existent-file.py happens to be a Python expression that raises NameError; the property (stdout EOF fails initialize with CONNECTION_CLOSED) is now pinned in process. - The basic/early-parent cleanup tests and universal-cleanup / graceful-stdin-exit tests, folded into the consolidated tree test and the in-process graceful/escalation tests. - tests/issues/test_1027_win_unreachable_cleanup.py: its lifespan cleanup chain is covered by the interaction e2e's clean-exit marker plus the lifespan tests, it polled marker files with fixed sleeps, and it leaked its child process when an assertion failed mid-test. Its only helper module (tests/shared/test_win32_utils.py) goes with it. The MCPServer.run("stdio") coverage its subprocess scripts provided is replaced by an in-process test that drives run() over injected stdio and asserts a real response. tests/issues/test_552_windows_hang.py now asserts initialize succeeded instead of swallowing every exception (its handcrafted response also sent the invalid protocolVersion "1.0", so it errored on every run and passed anyway), the stdio server tests are bounded by fail_after, and the elicitation tests that claimed "stdio" in their names run, and now say they run, over the in-memory transport.
1 parent 7437b94 commit b7cc0df

6 files changed

Lines changed: 530 additions & 609 deletions

File tree

0 commit comments

Comments
 (0)