* The suites that exercise the most of the project, widest first. * * Ranked by reach rather than by size or by module-level calls: a test's * useful property is how much of the codebase runs when it does, and only Go, * Rust and Java put that work inside functions where a "runs something at *
(cg: CodeGraph, limit: number)
| 366 | * name. |
| 367 | */ |
| 368 | function testFiles(cg: CodeGraph, limit: number): WireList<WireEntryTest> { |
| 369 | const candidates = cg |
| 370 | .getFiles() |
| 371 | .map((file) => toPosixPath(file.path)) |
| 372 | .filter((path) => isTestPath(path)); |
| 373 | if (candidates.length === 0) return wireList([], 0); |
| 374 | |
| 375 | const reach = new Map<string, { reaches: number; refs: number }>(); |
| 376 | for (let i = 0; i < candidates.length; i += TEST_CHUNK) { |
| 377 | for (const [path, counts] of cg.getFileReachCounts(candidates.slice(i, i + TEST_CHUNK))) { |
| 378 | reach.set(toPosixPath(path), counts); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | const ranked = [...reach.entries()] |
| 383 | .map(([path, counts]) => ({ path, ...counts })) |
| 384 | .sort((a, b) => b.reaches - a.reaches || b.refs - a.refs || a.path.localeCompare(b.path)); |
| 385 | |
| 386 | const top = ranked.slice(0, limit); |
| 387 | const nodes = new Map(cg.getFileNodes(top.map((row) => row.path)).map((n) => [toPosixPath(n.filePath), n])); |
| 388 | |
| 389 | const items: WireEntryTest[] = []; |
| 390 | for (const row of top) { |
| 391 | const node = nodes.get(row.path); |
| 392 | if (!node) continue; |
| 393 | items.push({ ...toNodeRef(node), reaches: row.reaches, refs: row.refs }); |
| 394 | } |
| 395 | |
| 396 | return wireList(items, Math.max(ranked.length, items.length)); |
| 397 | } |
| 398 | |
| 399 | /** The most depended-on symbols, tests, generated files and non-navigable kinds removed. */ |
| 400 | function hubs(cg: CodeGraph, limit: number): WireList<WireEntryHub> { |
no test coverage detected