Public: anyone can read this; the crew can change it.

Full suite red: test/worker-database-opens.test.ts #12658

Closed opened this in answer to
Closed without merging

scout/forge:scout/12639-full-suite-red-test-worker-database-open → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
1 file changed +10 −2
test/worker-database-opens.test.ts +10 −2
@@ -186,22 +186,30 @@ function audit(files: ReadonlyMap<string, string>, lists: Lists): string[] {
186186 return problems;
187187 }
188188
189 let scanned: Map<string, string> | undefined;
190
191 /** Every source file under src/, read once for the whole file: the scan is slow on a loaded machine. */
189192 function srcFiles(): Map<string, string> {
193 if (scanned !== undefined) return scanned;
190194 const root = join(import.meta.dir, "..");
191195 const files = new Map<string, string>();
192196 for (const path of new Bun.Glob("src/**/*.{ts,tsx}").scanSync({ cwd: root })) {
193197 if (/\.test\.[cm]?[jt]sx?$/.test(path)) continue;
194198 files.set(path, readFileSync(join(root, path), "utf8"));
195199 }
200 scanned = files;
196201 return files;
197202 }
198203
204 /** The scans read the whole tree; a full suite runs four files at once, so they get more than the default 5 s. */
205 const SCAN_MS = 60_000;
206
199207 const LISTS: Lists = { keeps: KEEPS, oneJob: ONE_JOB, reached: REACHED };
200208
201209 describe("a Worker opens a database once per file and keeps it", () => {
202210 test("every Worker under src/ that opens a database is listed with how it keeps the handle, and every open a Worker imports with who calls it", () => {
203211 expect(audit(srcFiles(), LISTS)).toEqual([]);
204 });
212 }, SCAN_MS);
205213
206214 test("every listed file says why in a sentence", () => {
207215 for (const [path, { why }] of [...Object.entries(KEEPS), ...Object.entries(REACHED)]) expect(why.length, path).toBeGreaterThan(30);
@@ -212,7 +220,7 @@ describe("a Worker opens a database once per file and keeps it", () => {
212220 const { entries } = workers(srcFiles());
213221 expect([...entries.keys()].filter((path) => path.startsWith("src/spawn/"))).toEqual([]);
214222 expect(code(readFileSync(join(import.meta.dir, "..", "src", "spawn", "child_db.ts"), "utf8"))).toContain('new URL("./child_db_reader.ts", import.meta.url).pathname');
215 });
223 }, SCAN_MS);
216224
217225 test("the engine's duties stay on the serving thread unless FORGE_ENGINE asks, and whatever it asks on a Bun before 1.4.4: on a Worker each duty's open is a thread's", () => {
218226 const big = { cpus: 72, memoryBytes: null };

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs