MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / resolveCandidateDirectories

Function resolveCandidateDirectories

src/utils/test-preflight.ts:276–322  ·  view source on GitHub ↗
(
  reference: ReferencedTestTarget,
  params: { workspacePath?: string; projectPath?: string },
  fileSystemExecutor: FileSystemExecutor,
)

Source from the content-addressed store, hash-verified

274}
275
276async function resolveCandidateDirectories(
277 reference: ReferencedTestTarget,
278 params: { workspacePath?: string; projectPath?: string },
279 fileSystemExecutor: FileSystemExecutor,
280): Promise<string[]> {
281 const roots = new Set<string>();
282 const workspacePath = params.workspacePath ? path.resolve(params.workspacePath) : undefined;
283 const projectPath = params.projectPath ? path.resolve(params.projectPath) : undefined;
284
285 if (reference.containerPath) {
286 const baseDir = path.dirname(workspacePath ?? projectPath ?? process.cwd());
287 const resolvedContainer = resolveContainerReference(reference.containerPath, baseDir);
288
289 if (resolvedContainer.endsWith('.xcodeproj')) {
290 const containerDir = path.dirname(resolvedContainer);
291 roots.add(path.join(containerDir, reference.name));
292 roots.add(path.join(containerDir, 'Tests', reference.name));
293 } else {
294 roots.add(path.join(resolvedContainer, 'Tests', reference.name));
295 roots.add(path.join(resolvedContainer, reference.name));
296 }
297 }
298
299 if (workspacePath) {
300 const workspaceDir = path.dirname(workspacePath);
301 roots.add(path.join(workspaceDir, reference.name));
302 roots.add(path.join(workspaceDir, 'Tests', reference.name));
303 }
304
305 if (projectPath) {
306 const projectDir = path.dirname(projectPath);
307 roots.add(path.join(projectDir, reference.name));
308 roots.add(path.join(projectDir, 'Tests', reference.name));
309 }
310
311 const results = await Promise.all(
312 [...roots].map(async (candidate) => {
313 try {
314 await fileSystemExecutor.stat(candidate);
315 return candidate;
316 } catch {
317 return null;
318 }
319 }),
320 );
321 return results.filter((candidate): candidate is string => candidate !== null);
322}
323
324function selectorMatches(test: DiscoveredTestCase, selector: TestSelector): boolean {
325 return (

Callers 1

resolveTestPreflightFunction · 0.85

Calls 3

resolveMethod · 0.80
statMethod · 0.80

Tested by

no test coverage detected