From 38ac4b808327af7214aea25941685d1d6f4d0a0e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 03:05:58 +0000 Subject: [PATCH] test(pty): stabilize non-windows signal assertion --- src/process/supervisor/adapters/pty.test.ts | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/process/supervisor/adapters/pty.test.ts b/src/process/supervisor/adapters/pty.test.ts index abacf7b70e4..c6753251be9 100644 --- a/src/process/supervisor/adapters/pty.test.ts +++ b/src/process/supervisor/adapters/pty.test.ts @@ -43,18 +43,26 @@ describe("createPtyAdapter", () => { vi.clearAllMocks(); }); - it("forwards explicit signals to node-pty kill", async () => { - spawnMock.mockReturnValue(createStubPty()); - const { createPtyAdapter } = await import("./pty.js"); + it("forwards explicit signals to node-pty kill on non-Windows", async () => { + const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform"); + Object.defineProperty(process, "platform", { value: "linux", configurable: true }); + try { + spawnMock.mockReturnValue(createStubPty()); + const { createPtyAdapter } = await import("./pty.js"); - const adapter = await createPtyAdapter({ - shell: "bash", - args: ["-lc", "sleep 10"], - }); + const adapter = await createPtyAdapter({ + shell: "bash", + args: ["-lc", "sleep 10"], + }); - adapter.kill("SIGTERM"); - expect(ptyKillMock).toHaveBeenCalledWith("SIGTERM"); - expect(killProcessTreeMock).not.toHaveBeenCalled(); + adapter.kill("SIGTERM"); + expect(ptyKillMock).toHaveBeenCalledWith("SIGTERM"); + expect(killProcessTreeMock).not.toHaveBeenCalled(); + } finally { + if (originalPlatform) { + Object.defineProperty(process, "platform", originalPlatform); + } + } }); it("uses process-tree kill for SIGKILL by default", async () => {