fix(test): preserve vitest force kill after idle timeout · openclaw/openclaw@3a1e49d
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -925,6 +925,36 @@ describe("scripts/run-vitest", () => {
|
925 | 925 | } |
926 | 926 | }); |
927 | 927 | |
| 928 | +it("keeps force-kill scheduled when output arrives after the idle timeout", () => { |
| 929 | +vi.useFakeTimers(); |
| 930 | +try { |
| 931 | +const stdout = new EventEmitter(); |
| 932 | +const timeoutSpy = vi.fn(); |
| 933 | +const forceKillSpy = vi.fn(); |
| 934 | + |
| 935 | +installVitestNoOutputWatchdog({ |
| 936 | +streams: [stdout], |
| 937 | +timeoutMs: 1000, |
| 938 | +forceKillAfterMs: 5000, |
| 939 | +onTimeout: timeoutSpy, |
| 940 | +onForceKill: forceKillSpy, |
| 941 | +setTimeoutFn: setTimeout, |
| 942 | +clearTimeoutFn: clearTimeout, |
| 943 | +}); |
| 944 | + |
| 945 | +vi.advanceTimersByTime(1000); |
| 946 | +expect(timeoutSpy).toHaveBeenCalledTimes(1); |
| 947 | + |
| 948 | +stdout.emit("data", "too late"); |
| 949 | +vi.advanceTimersByTime(5000); |
| 950 | + |
| 951 | +expect(timeoutSpy).toHaveBeenCalledTimes(1); |
| 952 | +expect(forceKillSpy).toHaveBeenCalledTimes(1); |
| 953 | +} finally { |
| 954 | +vi.useRealTimers(); |
| 955 | +} |
| 956 | +}); |
| 957 | + |
928 | 958 | it("prints bounded heartbeats before killing silent vitest runs", () => { |
929 | 959 | vi.useFakeTimers(); |
930 | 960 | try { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。