testsReaching
The tests a definition reaches: tests among what uses it, however far (up to limit definitions looked at).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { isTestPath } from "#codebase/tcmts/cli/testing"; import { outcomeOf } from "#codebase/tcmts/share"; export function testsReaching( cb: Codebase, hash: string, limit = 3000, ): { path: string; hash: string; ok?: boolean }[] { const seen = new Set([hash]); const queue = [hash]; const tests: { path: string; hash: string; ok?: boolean }[] = []; while (queue.length && seen.size < limit) { for (const d of cb.store.namedDependents(queue.shift()!)) { if (seen.has(d)) continue; seen.add(d); queue.push(d); const path = cb.store.pathsOf(d).find(isTestPath); if (path) tests.push({ path, hash: d, ...outcomeOf(cb, d) }); } } return tests.sort((a, b) => (a.path < b.path ? -1 : 1)); }