MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / testCodeReading

Function testCodeReading

src/graph/test-code.ts:44–63  ·  view source on GitHub ↗
(projectRoot: string)

Source from the content-addressed store, hash-verified

42 * tools both read through this, so the two never disagree on what a test is.
43 */
44export function testCodeReading(projectRoot: string): (node: Node) => boolean {
45 const sources = new Map<string, string | undefined>();
46 const readSource: SourceReader = (filePath) => {
47 if (!sources.has(filePath)) {
48 let text: string | undefined;
49 try {
50 const abs = validatePathWithinRoot(projectRoot, filePath);
51 text = abs === null ? undefined : readFileSync(abs, 'utf-8');
52 } catch { /* unreadable → not known to be test code */ }
53 sources.set(filePath, text);
54 }
55 return sources.get(filePath);
56 };
57 const verdicts = new Map<string, boolean>();
58 return (node) => {
59 let v = verdicts.get(node.id);
60 if (v === undefined) verdicts.set(node.id, (v = isTestCode(node, readSource)));
61 return v;
62 };
63}
64
65/**
66 * `filePath` (project-relative) is a Rust module file its parent declares

Callers 2

testCodeReadingMethod · 0.90
mainFunction · 0.90

Calls 3

isTestCodeFunction · 0.70
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected