@@ -161,37 +161,37 @@ function isSkippedTrackedTestFile(relativePath: string) {
161161let trackedRepoTestFiles : string [ ] | null | undefined ;
162162// Large checkouts exceed Node's 1 MiB spawnSync default. Preserve the Git inventory path;
163163// ENOBUFS would otherwise trigger expensive extension-directory walks.
164- const GIT_LS_FILES_MAX_BUFFER_BYTES = 16 * 1024 * 1024 ;
165-
166- function loadTrackedRepoTestFiles ( ) {
167- if ( trackedRepoTestFiles !== undefined ) {
168- return trackedRepoTestFiles ;
169- }
164+ export const GIT_LS_FILES_MAX_BUFFER_BYTES = 16 * 1024 * 1024 ;
170165
166+ export function listTrackedTestPlanFiles ( cwd : string , pathspecs : readonly string [ ] ) {
171167 // Query only the planner-owned tree: a full-repo inventory can overflow
172168 // spawnSync's buffer and either truncate the plan or force directory walks.
173- const result = spawnSync ( "git" , [ "ls-files" , "--" , ...TRACKED_EXTENSION_TEST_PATHSPECS ] , {
174- cwd : repoRoot ,
169+ const result = spawnSync ( "git" , [ "ls-files" , "--" , ...pathspecs ] , {
170+ cwd,
175171 encoding : "utf8" ,
176172 maxBuffer : GIT_LS_FILES_MAX_BUFFER_BYTES ,
177173 stdio : [ "ignore" , "pipe" , "ignore" ] ,
178174 } ) ;
179175 if ( result . status !== 0 || result . error ) {
180- trackedRepoTestFiles = null ;
181- return trackedRepoTestFiles ;
176+ return null ;
182177 }
178+ return result . stdout
179+ . split ( "\n" )
180+ . map ( ( line ) => line . trim ( ) . replaceAll ( "\\" , "/" ) )
181+ . filter ( Boolean ) ;
182+ }
183183
184+ function loadTrackedRepoTestFiles ( ) {
184185 // Tracked repository metadata is immutable during one planner invocation.
185186 // Reuse one inventory so broad extension plans do not fork Git per plugin.
186- trackedRepoTestFiles = result . stdout
187- . split ( "\n" )
188- . map ( ( line ) => line . trim ( ) . replaceAll ( "\\" , "/" ) )
189- . filter (
190- ( line ) =>
191- line . length > 0 &&
192- ! isSkippedTrackedTestFile ( line ) &&
193- ( line . endsWith ( ".test.ts" ) || line . endsWith ( ".test.tsx" ) ) ,
194- ) ;
187+ if ( trackedRepoTestFiles === undefined ) {
188+ trackedRepoTestFiles =
189+ listTrackedTestPlanFiles ( repoRoot , TRACKED_EXTENSION_TEST_PATHSPECS ) ?. filter (
190+ ( line ) =>
191+ ! isSkippedTrackedTestFile ( line ) &&
192+ ( line . endsWith ( ".test.ts" ) || line . endsWith ( ".test.tsx" ) ) ,
193+ ) ?? null ;
194+ }
195195 return trackedRepoTestFiles ;
196196}
197197
0 commit comments