MCPcopy Index your code
hub / github.com/react/react / readTestFilter

Function readTestFilter

compiler/packages/snap/src/fixture-utils.ts:47–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47export async function readTestFilter(): Promise<TestFilter | null> {
48 if (!(await exists(FILTER_PATH))) {
49 throw new Error(`testfilter file not found at \`${FILTER_PATH}\``);
50 }
51
52 const input = await fs.readFile(FILTER_PATH, 'utf8');
53 const lines = input.trim().split('\n');
54
55 let debug: boolean = false;
56 const line0 = lines[0];
57 if (line0 != null) {
58 // Try to parse pragmas
59 let consumedLine0 = false;
60 if (line0.indexOf('@only') !== -1) {
61 consumedLine0 = true;
62 }
63 if (line0.indexOf('@debug') !== -1) {
64 debug = true;
65 consumedLine0 = true;
66 }
67
68 if (consumedLine0) {
69 lines.shift();
70 }
71 }
72 return {
73 debug,
74 paths: lines.filter(line => !line.trimStart().startsWith('//')),
75 };
76}
77
78export function getBasename(fixture: TestFixture): string {
79 return stripExtension(path.basename(fixture.inputPath), INPUT_EXTENSIONS);

Callers 4

mainFunction · 0.90
subscribeFilterFileFunction · 0.90
subscribeKeyEventsFunction · 0.90
makeWatchRunnerFunction · 0.90

Calls 1

existsFunction · 0.85

Tested by

no test coverage detected