@@ -70,24 +70,17 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
7070
7171 /**
7272 * Feature flag for project-based testing.
73- * Set to true to enable multi-project testing support (Phases 2-4 must be complete) .
74- * Default: false (use legacy single-workspace mode)
73+ * When true, discovers and manages tests per-project using Python Environments API .
74+ * When false, uses legacy single-workspace mode.
7575 */
7676 private readonly useProjectBasedTesting = true ;
7777
7878 // Legacy: Single workspace test adapter per workspace (backward compatibility)
7979 private readonly testAdapters : Map < Uri , WorkspaceTestAdapter > = new Map ( ) ;
8080
81- // === NEW: PROJECT-BASED STATE ===
82- // Map of workspace URI -> Map of project URI string -> ProjectAdapter
83- // Note: Project URI strings match Python Environments extension's Map<string, PythonProject> keys
81+ // Project-based testing: Maps workspace URI -> project ID -> ProjectAdapter
8482 private readonly workspaceProjects : Map < Uri , Map < string , ProjectAdapter > > = new Map ( ) ;
8583
86- // TODO: Phase 3-4 - Add these maps when implementing execution:
87- // - vsIdToProject: Map<string, ProjectAdapter> - Fast lookup for test execution
88- // - fileUriToProject: Map<string, ProjectAdapter> - File watching and change detection
89- // - projectToVsIds: Map<string, Set<string>> - Project cleanup and refresh
90-
9184 private readonly triggerTypes : TriggerType [ ] = [ ] ;
9285
9386 private readonly testController : TestController ;
@@ -333,7 +326,7 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
333326 const pythonProjects = envExtApi . getPythonProjects ( ) ;
334327 traceInfo ( `[test-by-project] Found ${ pythonProjects . length } total Python projects from API` ) ;
335328
336- // Filter projects to only those in this workspace TODO; check this
329+ // Filter projects to only those in this workspace
337330 const workspaceProjects = pythonProjects . filter ( ( project ) =>
338331 isParentPath ( project . uri . fsPath , workspaceUri . fsPath ) ,
339332 ) ;
@@ -567,14 +560,11 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
567560 }
568561
569562 /**
570- * Phase 3: Identifies which projects are nested within other projects in the same workspace.
563+ * Identifies which projects are nested within other projects in the same workspace.
571564 * Returns a map of parent project ID -> array of nested child project paths to ignore.
572565 *
573566 * Example: If ProjectB (alice/bob/) is nested in ProjectA (alice/),
574567 * returns: { "projectA-id": ["alice/bob"] }
575- *
576- * Uses simple path prefix matching - a project is nested if its path starts with
577- * another project's path followed by a path separator.
578568 */
579569 private computeNestedProjectIgnores ( workspaceUri : Uri ) : Map < string , string [ ] > {
580570 const projectIgnores = new Map < string , string [ ] > ( ) ;
@@ -623,9 +613,8 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
623613 }
624614
625615 /**
626- * Phase 2: Discovers tests for all projects within a workspace (project-based testing).
627- * Runs discovery in parallel for all projects and tracks file overlaps for Phase 3.
628- * Each project populates its TestItems independently using the existing discovery flow.
616+ * Discovers tests for all projects within a workspace.
617+ * Runs discovery in parallel and configures nested project exclusions.
629618 */
630619 private async refreshWorkspaceProjects ( workspaceUri : Uri ) : Promise < void > {
631620 const projectsMap = this . workspaceProjects . get ( workspaceUri ) ;
@@ -638,7 +627,7 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
638627 traceInfo ( `[test-by-project] Starting discovery for ${ projects . length } project(s) in workspace` ) ;
639628
640629 try {
641- // PHASE 3: Compute nested project relationships BEFORE discovery
630+ // Compute nested project relationships BEFORE discovery
642631 const projectIgnores = this . computeNestedProjectIgnores ( workspaceUri ) ;
643632
644633 // Populate each project's ignore list by iterating through projects array directly
@@ -672,34 +661,18 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
672661
673662 /**
674663 * Runs test discovery for a single project.
675- * Uses the existing discovery flow which populates TestItems automatically.
676664 */
677665 private async discoverProject ( project : ProjectAdapter , projectsCompleted : Set < string > ) : Promise < void > {
678666 try {
679667 traceInfo ( `[test-by-project] Discovering tests for project: ${ project . projectName } ` ) ;
680668 project . isDiscovering = true ;
681669
682- // Run discovery using project's adapter with project's interpreter
683- // This will call the existing discovery flow which populates TestItems via result resolver
684- // Note: The adapter expects the legacy PythonEnvironment type, but for now we can pass
685- // the environment from the API. The adapters internally use execInfo which both types have.
686- //
687- // Pass the ProjectAdapter so discovery adapters can extract project.projectUri.fsPath
688- // and set PROJECT_ROOT_PATH environment variable. This tells Python subprocess where to
689- // trim the test tree, keeping test paths relative to project root instead of workspace root,
690- // while preserving CWD for user's test configurations.
691- //
692- // TODO: Symlink consideration - If project.projectUri.fsPath contains symlinks,
693- // Python's path resolution may differ from Node.js. Discovery adapters should consider
694- // using fs.promises.realpath() to resolve symlinks before passing PROJECT_ROOT_PATH to Python,
695- // similar to handleSymlinkAndRootDir() in pytest. This ensures PROJECT_ROOT_PATH matches
696- // the resolved path Python will use.
697670 await project . discoveryAdapter . discoverTests (
698671 project . projectUri ,
699672 this . pythonExecFactory ,
700673 this . refreshCancellation . token ,
701- project . pythonEnvironment as any , // Type cast needed - API type vs legacy type
702- project , // Pass project for access to projectUri and other project-specific data
674+ project . pythonEnvironment as any ,
675+ project ,
703676 ) ;
704677
705678 // Mark project as completed
0 commit comments