



























@@ -672,8 +672,8 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
672672mockSpawnSync.mockImplementation(() => ({ error: null, status: 1, stdout: "", stderr: "" }));
673673674674vi.spyOn(process, "kill").mockReturnValue(true);
675-// Must not throw — the catch path returns transient inconclusive, loop continues
676-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
675+// The catch path returns transient inconclusive, then the loop continues.
676+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
677677});
678678});
679679@@ -777,7 +777,7 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
777777});
778778779779vi.spyOn(process, "kill").mockReturnValue(true);
780-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
780+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
781781782782// Must bail after first ENOENT poll — no point retrying a missing binary
783783const enoentPolls = events.filter((e) => e.startsWith("enoent-poll"));
@@ -792,7 +792,7 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
792792createErrnoResult("EPERM", "lsof eperm"),
793793);
794794vi.spyOn(process, "kill").mockReturnValue(true);
795-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
795+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
796796// Must bail after exactly 1 EPERM poll — same as ENOENT/EACCES
797797expect(getCallCount()).toBe(2); // 1 initial find + 1 EPERM poll
798798});
@@ -805,7 +805,7 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
805805createErrnoResult("EACCES", "lsof permission denied"),
806806);
807807vi.spyOn(process, "kill").mockReturnValue(true);
808-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
808+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
809809// Should have bailed after exactly 1 poll call (the EACCES one)
810810expect(getCallCount()).toBe(2); // 1 initial find + 1 EACCES poll
811811});
@@ -826,8 +826,8 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
826826});
827827828828vi.spyOn(process, "kill").mockReturnValue(true);
829-// Must return without throwing (proceeds with warning after budget expires)
830-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
829+// Proceeds with warning after budget expires.
830+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
831831});
832832833833it("still polls for port-free when all stale pids were already dead at SIGTERM time", () => {
@@ -1199,8 +1199,8 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
11991199});
12001200});
12011201vi.spyOn(process, "kill").mockReturnValue(true);
1202-// Should complete cleanly — no openclaw pids in status-1 output → free
1203-expect(() => cleanStaleGatewayProcessesSync()).not.toThrow();
1202+// No openclaw pids in status-1 output means the port is free for this cleanup.
1203+expect(cleanStaleGatewayProcessesSync()).toContain(stalePid);
12041204// Completed with one argv verification after the status-1 poll output:
12051205// initial lsof + poll lsof + ps argv check.
12061206expect(getCallCount()).toBe(3);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。