дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 01:31:41 +02:00
Failed warmups and repetitions were dropped from benchmark summaries, a failed startup, build or cleanup could leave an earlier success report in place, and a hung renderer or child process could block a run. Every attempt now keeps its status, metrics and error so summaries have the complete denominator; failures replace stale reports; browser and child-process lifecycles are bounded with cleanup of owned resources; and each criterion execution gets its own artifact directory. Co-authored-by: Mr0Bread <[email protected]>
43 рядки
1.5 KiB
TypeScript
43 рядки
1.5 KiB
TypeScript
// @vitest-environment node
|
|
import { expect, test, vi } from "vitest";
|
|
import { launchBrowser, withDeadline } from "./lifecycle.ts";
|
|
|
|
test("a deadline rejects an unanswered operation and releases its timer", async () => {
|
|
vi.useFakeTimers();
|
|
try {
|
|
const pending = withDeadline(Promise.withResolvers<void>().promise, 20, "RPC");
|
|
const assertion = expect(pending).rejects.toThrow("RPC timed out after 20 ms");
|
|
await vi.advanceTimersByTimeAsync(20);
|
|
await assertion;
|
|
expect(vi.getTimerCount()).toBe(0);
|
|
} finally {
|
|
vi.useRealTimers();
|
|
}
|
|
});
|
|
|
|
test.each(["blocked renderer", "missing animation frames"])(
|
|
"Node deadline survives %s and browser cleanup terminates it",
|
|
{ timeout: 20_000 },
|
|
async (mode) => {
|
|
const runtime = await launchBrowser({ headless: true });
|
|
try {
|
|
const page = await runtime.browser.newPage();
|
|
// Real renderer/Node clocks are the boundary under test; fake timers cannot drive Chromium.
|
|
const operation =
|
|
mode === "blocked renderer"
|
|
? page.evaluate(() => {
|
|
for (;;) {
|
|
/* Deliberately unresponsive renderer. */
|
|
}
|
|
})
|
|
: page.evaluate(() => {
|
|
window.requestAnimationFrame = () => 0;
|
|
return new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
|
});
|
|
await expect(withDeadline(operation, 30, mode)).rejects.toThrow("wall clock");
|
|
} finally {
|
|
await runtime.close();
|
|
}
|
|
},
|
|
);
|