From d653052508998144e39357a37f72a12448c769f1 Mon Sep 17 00:00:00 2001 From: lorenzozanee Date: Tue, 8 Sep 2026 12:17:34 +0800 Subject: [PATCH 1/2] test(windows): guard clean MCP stdio startup Signed-off-by: lorenzozanee --- scripts/test-windows.ps1 | 1 + tests/windows/test_mcp_stdio.py | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/windows/test_mcp_stdio.py diff --git a/scripts/test-windows.ps1 b/scripts/test-windows.ps1 index 8c1a8358a..0022560f3 100644 --- a/scripts/test-windows.ps1 +++ b/scripts/test-windows.ps1 @@ -166,6 +166,7 @@ $guards = @( "tests\windows\test_hook_augment.py", "tests\windows\test_ui_drive_listing.py", "tests\windows\test_cli_non_ascii_arg.py", + "tests\windows\test_mcp_stdio.py", "tests\windows\test_windows_update_handoff.py" ) diff --git a/tests/windows/test_mcp_stdio.py b/tests/windows/test_mcp_stdio.py new file mode 100644 index 000000000..68911c877 --- /dev/null +++ b/tests/windows/test_mcp_stdio.py @@ -0,0 +1,41 @@ +"""Regression guard for clean Windows MCP stdio startup.""" + +import os +import sys +import tempfile + +from mcp_stdio import McpServer + + +def main(): + if os.name != "nt": + print("SKIP: Windows-only MCP stdio guard") + return 2 + + binary = sys.argv[1] if len(sys.argv) > 1 else os.environ.get("CBM_TEST_BINARY") + if not binary: + print("SETUP FAIL: CBM_TEST_BINARY is required", file=sys.stderr) + return 2 + + with tempfile.TemporaryDirectory(prefix="cbm-mcp-stdio-") as cache: + with McpServer(binary, cache_dir=cache) as server: + server.initialize(timeout=30) + server.tools_list(timeout=30) + server.close() + stderr = server.stderr_text() + + forbidden = ( + "The system cannot find the path specified.", + "El sistema no puede encontrar la ruta especificada.", + ) + leaked = [message for message in forbidden if message in stderr] + if leaked: + print("FAIL: startup leaked an OS path error to stderr: " + ", ".join(leaked), + file=sys.stderr) + return 1 + print("PASS: successful MCP startup emitted no OS path error") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From d9dec5dd3b334a514113670b42732ca9ea4a15de Mon Sep 17 00:00:00 2001 From: lorenzozanee Date: Tue, 8 Sep 2026 14:22:22 +0800 Subject: [PATCH 2/2] test(windows): guard clean MCP stdio startup Signed-off-by: lorenzozanee --- tests/windows/test_mcp_stdio.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/windows/test_mcp_stdio.py b/tests/windows/test_mcp_stdio.py index 68911c877..9406bf0c8 100644 --- a/tests/windows/test_mcp_stdio.py +++ b/tests/windows/test_mcp_stdio.py @@ -1,6 +1,7 @@ """Regression guard for clean Windows MCP stdio startup.""" import os +import subprocess import sys import tempfile @@ -18,11 +19,26 @@ def main(): return 2 with tempfile.TemporaryDirectory(prefix="cbm-mcp-stdio-") as cache: - with McpServer(binary, cache_dir=cache) as server: - server.initialize(timeout=30) - server.tools_list(timeout=30) - server.close() + runtime = os.path.join(os.path.dirname(cache), "cbm-mcp-stdio-runtime") + os.makedirs(runtime) + server = McpServer(binary, cache_dir=cache, + extra_env={"CBM_RUNTIME_DIR": runtime}) + try: + with server: + server.initialize(timeout=30) + server.tools_list(timeout=30) stderr = server.stderr_text() + finally: + stop = subprocess.run( + [binary, "daemon", "stop"], + env=server.env, + capture_output=True, + timeout=30, + ) + if stop.returncode != 0: + detail = (stop.stdout + stop.stderr).decode("utf-8", "replace") + raise RuntimeError("daemon cleanup failed (%d): %s" % + (stop.returncode, detail.strip())) forbidden = ( "The system cannot find the path specified.",