|
| 1 | +import type { CheckProgress } from "../utils/checkProgress.js"; |
1 | 2 | import { runCommand } from "citty"; |
2 | 3 | import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
3 | 4 | import { tmpdir } from "node:os"; |
@@ -2280,6 +2281,40 @@ describe("check pipeline", () => { |
2280 | 2281 | } |
2281 | 2282 | }); |
2282 | 2283 |
|
| 2284 | + it("slow analysis calls that each finish keep the check alive past 120 s", async () => { |
| 2285 | + vi.useFakeTimers(); |
| 2286 | + try { |
| 2287 | + let analysing = false; |
| 2288 | + const slowWhenAnalysing = async () => { |
| 2289 | + if (analysing) await new Promise((resolve) => setTimeout(resolve, 100_000)); |
| 2290 | + }; |
| 2291 | + const hasNoTimelineDeclaration = vi.fn(async () => { |
| 2292 | + await slowWhenAnalysing(); |
| 2293 | + return false; |
| 2294 | + }); |
| 2295 | + const getCanvas = vi.fn(async () => { |
| 2296 | + await slowWhenAnalysing(); |
| 2297 | + return { width: 1920, height: 1080 }; |
| 2298 | + }); |
| 2299 | + const driver = fakeDriver({ hasNoTimelineDeclaration, getCanvas }); |
| 2300 | + const { deps } = dependencies(driver); |
| 2301 | + deps.runBrowserCheck = async (_project, options, motion, deadline) => { |
| 2302 | + deadline!.start(); |
| 2303 | + const report: CheckProgress = (phase) => { |
| 2304 | + if (phase === "analyze") analysing = true; |
| 2305 | + }; |
| 2306 | + return runAuditGrid(driver, options, motion, undefined, deadline!.enter, report); |
| 2307 | + }; |
| 2308 | + const pending = runCheckPipeline(PROJECT, DEFAULT_CHECK_OPTIONS, deps); |
| 2309 | + await vi.advanceTimersByTimeAsync(2_000_000); |
| 2310 | + const codes = (await pending).runtime.findings.map((finding) => finding.code); |
| 2311 | + expect(codes).not.toContain("check_runtime_failure"); |
| 2312 | + expect(hasNoTimelineDeclaration).toHaveBeenCalled(); |
| 2313 | + } finally { |
| 2314 | + vi.useRealTimers(); |
| 2315 | + } |
| 2316 | + }); |
| 2317 | + |
2283 | 2318 | it("a long overlap pass that keeps reporting progress finishes instead of hitting a wall clock", async () => { |
2284 | 2319 | vi.useFakeTimers(); |
2285 | 2320 | try { |
|
0 commit comments