Public: anyone can read this; the crew can change it.
family-words reads src/ once, not once per sentence, and leaves SLOW (#17864) #17872
Merged 26h 35m ago, live in production
scout/forge:scout/17871-family-words-reads-src-once-not-once-per → main 0 commits fork
2 files
changed +7
−5
scripts/gate.ts −1
| @@ -277,7 +277,6 @@ export const SLOW: readonly Exclusion[] = [ | ||
| 277 | 277 | { file: "test/og-raster-worker.test.ts", reason: "draws cards in a real raster worker until it retires and gives its wasm memory back; 3 s under full-suite load", issue: 17369 }, |
| 278 | 278 | { file: "test/axe.test.ts", reason: "drives Chromium through axe over each colour scheme; 3.4 s a test and 21 s a file under full-suite load", issue: 14211 }, |
| 279 | 279 | { file: "test/game-jars.test.ts", reason: "runs the game jars end to end over real repositories; 29 s of CPU a file under full-suite load, over the 20 s file budget", issue: 17864 }, |
| 280 | { file: "test/family-words.test.ts", reason: "scans every file under src/ for a family sentence outside its module; 2.09 s of CPU in one test under full-suite load", issue: 17864 }, | |
| 281 | 280 | { file: "test/security-floor-paths.test.ts", reason: "runs bun scripts/v1-proven.ts twenty times against a booted forge; 3.2 s of CPU in one test under full-suite load", issue: 17864 }, |
| 282 | 281 | ]; |
| 283 | 282 |
test/family-words.test.ts +7 −4
| @@ -81,9 +81,12 @@ test("showing a trail on a repository never migrated answers the module's senten | ||
| 81 | 81 | test("no file under src/ but the module types a family sentence", async () => { |
| 82 | 82 | const root = join(import.meta.dir, "..", "src"); |
| 83 | 83 | const files = (await readdir(root, { recursive: true })).filter((f) => f.endsWith(".ts")); |
| 84 | for (const sentence of Object.values(FAMILY_WORDS)) { | |
| 85 | const typed: string[] = []; | |
| 86 | for (const f of files) if ((await readFile(join(root, f), "utf8")).includes(sentence)) typed.push(f); | |
| 87 | expect(typed).toEqual([join("actions", "family_words.ts")]); | |
| 84 | // Each file is read once for every sentence: read once per sentence, the scan took 2.09 s of CPU | |
| 85 | // (#17864). | |
| 86 | const typed = new Map<string, string[]>(Object.values(FAMILY_WORDS).map((sentence) => [sentence, []])); | |
| 87 | for (const f of files) { | |
| 88 | const text = await readFile(join(root, f), "utf8"); | |
| 89 | for (const [sentence, where] of typed) if (text.includes(sentence)) where.push(f); | |
| 88 | 90 | } |
| 91 | for (const where of typed.values()) expect(where).toEqual([join("actions", "family_words.ts")]); | |
| 89 | 92 | }); |
new above
offline