Skip to content

Commit 79e3ef5

Browse files
committed
bugc: let the event loop turn while the template tests read
A long run of reads never turned the event loop, and vitest failed the run with 'Timeout calling "onTaskUpdate"'.
1 parent e6b146c commit 79e3ef5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎packages/bugc/src/irgen/debug/templates.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* them. `UPDATE_TEMPLATES_GOLDEN=1` writes it again from the
1414
* compiler at hand, so it is written with a compiler from before.
1515
*/
16-
import { describe, it, expect, afterAll } from "vitest";
16+
import { describe, it, expect, afterAll, afterEach } from "vitest";
1717
import { createHash } from "crypto";
1818
import { promises as fs } from "fs";
1919
import path from "path";
@@ -159,6 +159,8 @@ async function eachPointer(
159159
const entries = localsOf(context).filter(({ pointer }) => pointer);
160160
if (entries.length === 0) continue;
161161
const state = run.stateAt(k + 1);
162+
// (give the event loop a turn; see `afterEach` below)
163+
await new Promise<void>((resolve) => setImmediate(resolve));
162164
for (const { identifier, pointer } of entries) {
163165
const label = `${calldata.slice(0, 8)} ${k} ${identifier}`;
164166
await visit(label, pointer as Format.Pointer, state, templates);
@@ -173,6 +175,12 @@ async function eachPointer(
173175
}
174176
}
175177

178+
// A long run of reads never turns the event loop, so the worker cannot
179+
// read vitest's replies to its progress reports, and once that lasts a
180+
// minute, vitest fails the run with 'Timeout calling "onTaskUpdate"'
181+
// (as in test/examples/examples.test.ts).
182+
afterEach(() => new Promise<void>((resolve) => setImmediate(resolve)));
183+
176184
async function examples(): Promise<Array<[string, string]>> {
177185
const files = await glob("**/*.bug", { cwd: EXAMPLES_DIR });
178186
const sources: Array<[string, string]> = [];

0 commit comments

Comments
 (0)