From 4e3bf7ce6a9cf899de1dc2ebaadad0d7574557e5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 25 Apr 2026 14:09:31 +0100 Subject: [PATCH] test: scope gateway restart signal assertion --- src/agents/openclaw-gateway-tool.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/agents/openclaw-gateway-tool.test.ts b/src/agents/openclaw-gateway-tool.test.ts index eefb0a78403..3a14533d021 100644 --- a/src/agents/openclaw-gateway-tool.test.ts +++ b/src/agents/openclaw-gateway-tool.test.ts @@ -98,6 +98,10 @@ describe("gateway tool", () => { it("schedules SIGUSR1 restart", async () => { const kill = vi.spyOn(process, "kill").mockImplementation(() => true); + const restartSignalKillCalls = () => + kill.mock.calls.filter( + ([pid, signal]) => pid === process.pid && (signal === "SIGUSR1" || signal === undefined), + ); const sigusr1Handler = vi.fn(); process.on("SIGUSR1", sigusr1Handler); const stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-test-")); @@ -119,13 +123,13 @@ describe("gateway tool", () => { delayMs: 0, }); - expect(kill).not.toHaveBeenCalled(); + expect(restartSignalKillCalls()).toHaveLength(0); expect(sigusr1Handler).not.toHaveBeenCalled(); await vi.waitFor(() => expect(sigusr1Handler).toHaveBeenCalledTimes(1), { interval: 1, timeout: 1_000, }); - expect(kill).not.toHaveBeenCalled(); + expect(restartSignalKillCalls()).toHaveLength(0); const sentinelPath = path.join(stateDir, "restart-sentinel.json"); const raw = await fs.readFile(sentinelPath, "utf-8");