mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:00:42 +00:00
fix(test): include vitest lane labels in timeout logs
This commit is contained in:
@@ -59,6 +59,8 @@ export function installVitestNoOutputWatchdog(params) {
|
||||
const clearTimeoutFn = params.clearTimeoutFn ?? clearTimeout;
|
||||
const forceKillAfterMs = params.forceKillAfterMs ?? 5_000;
|
||||
const streams = params.streams?.filter(Boolean) ?? [];
|
||||
const label = params.label?.trim();
|
||||
const suffix = label ? ` (${label})` : "";
|
||||
|
||||
let active = true;
|
||||
let silenceTimer = null;
|
||||
@@ -88,7 +90,7 @@ export function installVitestNoOutputWatchdog(params) {
|
||||
return;
|
||||
}
|
||||
params.log?.(
|
||||
`[vitest] no output for ${timeoutMs}ms; terminating stalled Vitest process group.`,
|
||||
`[vitest] no output for ${timeoutMs}ms; terminating stalled Vitest process group${suffix}.`,
|
||||
);
|
||||
params.onTimeout?.();
|
||||
if (forceKillAfterMs > 0) {
|
||||
@@ -98,7 +100,7 @@ export function installVitestNoOutputWatchdog(params) {
|
||||
return;
|
||||
}
|
||||
params.log?.(
|
||||
`[vitest] process group still alive after ${forceKillAfterMs}ms; sending SIGKILL.`,
|
||||
`[vitest] process group still alive after ${forceKillAfterMs}ms; sending SIGKILL${suffix}.`,
|
||||
);
|
||||
params.onForceKill?.();
|
||||
}, forceKillAfterMs);
|
||||
@@ -177,6 +179,7 @@ function main(argv = process.argv.slice(2), env = process.env) {
|
||||
const teardownNoOutputWatchdog = installVitestNoOutputWatchdog({
|
||||
streams: [child.stdout, child.stderr],
|
||||
timeoutMs: resolveVitestNoOutputTimeoutMs(env),
|
||||
label: argv.join(" "),
|
||||
log: (message) => {
|
||||
console.error(message);
|
||||
},
|
||||
|
||||
@@ -120,6 +120,7 @@ function runVitestSpec(spec) {
|
||||
const teardownNoOutputWatchdog = installVitestNoOutputWatchdog({
|
||||
streams: [child.stdout, child.stderr],
|
||||
timeoutMs: resolveVitestNoOutputTimeoutMs(spec.env),
|
||||
label: spec.config,
|
||||
log: (message) => {
|
||||
console.error(message);
|
||||
},
|
||||
|
||||
@@ -97,4 +97,28 @@ describe("scripts/run-vitest", () => {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("includes the runner label in watchdog logs when provided", () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const stdout = new EventEmitter();
|
||||
const logSpy = vi.fn();
|
||||
|
||||
installVitestNoOutputWatchdog({
|
||||
streams: [stdout],
|
||||
timeoutMs: 1000,
|
||||
forceKillAfterMs: 0,
|
||||
label: "run --config test/vitest/vitest.secrets.config.ts",
|
||||
log: logSpy,
|
||||
onTimeout: () => {},
|
||||
});
|
||||
|
||||
vi.advanceTimersByTime(1000);
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
"[vitest] no output for 1000ms; terminating stalled Vitest process group (run --config test/vitest/vitest.secrets.config.ts).",
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user