@@ -53,7 +53,7 @@ import { ITestDebugLauncher } from '../common/types';
5353import { PythonResultResolver } from './common/resultResolver' ;
5454import { onDidSaveTextDocument } from '../../common/vscodeApis/workspaceApis' ;
5555import { IEnvironmentVariablesProvider } from '../../common/variables/types' ;
56- import { ProjectAdapter , WorkspaceDiscoveryState } from './common/projectAdapter' ;
56+ import { ProjectAdapter } from './common/projectAdapter' ;
5757import { getProjectId , createProjectDisplayName } from './common/projectUtils' ;
5858import { PythonProject , PythonEnvironment } from '../../envExt/types' ;
5959import { getEnvExtApi , useEnvExtension } from '../../envExt/api.internal' ;
@@ -83,9 +83,6 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
8383 // Note: Project URI strings match Python Environments extension's Map<string, PythonProject> keys
8484 private readonly workspaceProjects : Map < Uri , Map < string , ProjectAdapter > > = new Map ( ) ;
8585
86- // Temporary state for tracking overlaps during discovery (created/destroyed per refresh)
87- private readonly workspaceDiscoveryState : Map < Uri , WorkspaceDiscoveryState > = new Map ( ) ;
88-
8986 // TODO: Phase 3-4 - Add these maps when implementing execution:
9087 // - vsIdToProject: Map<string, ProjectAdapter> - Fast lookup for test execution
9188 // - fileUriToProject: Map<string, ProjectAdapter> - File watching and change detection
@@ -640,17 +637,6 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
640637 const projects = Array . from ( projectsMap . values ( ) ) ;
641638 traceInfo ( `[test-by-project] Starting discovery for ${ projects . length } project(s) in workspace` ) ;
642639
643- // Initialize discovery state for overlap tracking
644- const discoveryState : WorkspaceDiscoveryState = {
645- workspaceUri,
646- fileToProjects : new Map ( ) ,
647- fileOwnership : new Map ( ) ,
648- projectsCompleted : new Set ( ) ,
649- totalProjects : projects . length ,
650- isComplete : false ,
651- } ;
652- this . workspaceDiscoveryState . set ( workspaceUri , discoveryState ) ;
653-
654640 try {
655641 // PHASE 3: Compute nested project relationships BEFORE discovery
656642 const projectIgnores = this . computeNestedProjectIgnores ( workspaceUri ) ;
@@ -669,38 +655,26 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
669655 }
670656 }
671657
658+ // Track completion for progress logging
659+ const projectsCompleted = new Set < string > ( ) ;
660+
672661 // Run discovery for all projects in parallel (now with ignore lists populated)
673662 // Each project will populate TestItems independently via existing flow
674- await Promise . all ( projects . map ( ( project ) => this . discoverProject ( project , discoveryState ) ) ) ;
663+ await Promise . all ( projects . map ( ( project ) => this . discoverProject ( project , projectsCompleted ) ) ) ;
675664
676- // Mark discovery complete
677- discoveryState . isComplete = true ;
678665 traceInfo (
679- `[test-by-project] Discovery complete: ${ discoveryState . projectsCompleted . size } /${ projects . length } projects succeeded` ,
680- ) ;
681-
682- // Log overlap information for debugging
683- const overlappingFiles = Array . from ( discoveryState . fileToProjects . entries ( ) ) . filter (
684- ( [ , projects ] ) => projects . size > 1 ,
666+ `[test-by-project] Discovery complete: ${ projectsCompleted . size } /${ projects . length } projects succeeded` ,
685667 ) ;
686- if ( overlappingFiles . length > 0 ) {
687- traceInfo ( `[test-by-project] Found ${ overlappingFiles . length } file(s) discovered by multiple projects` ) ;
688- }
689-
690- // TODO: Phase 3 - Resolve overlaps and rebuild test tree with proper ownership
691- // await this.resolveOverlapsAndAssignTests(workspaceUri);
692- } finally {
693- // Clean up temporary discovery state
694- this . workspaceDiscoveryState . delete ( workspaceUri ) ;
668+ } catch ( error ) {
669+ traceError ( `[test-by-project] Discovery failed for workspace ${ workspaceUri . fsPath } :` , error ) ;
695670 }
696671 }
697672
698673 /**
699- * Phase 2: Runs test discovery for a single project.
674+ * Runs test discovery for a single project.
700675 * Uses the existing discovery flow which populates TestItems automatically.
701- * Tracks which files were discovered for overlap detection in Phase 3.
702676 */
703- private async discoverProject ( project : ProjectAdapter , discoveryState : WorkspaceDiscoveryState ) : Promise < void > {
677+ private async discoverProject ( project : ProjectAdapter , projectsCompleted : Set < string > ) : Promise < void > {
704678 try {
705679 traceInfo ( `[test-by-project] Discovering tests for project: ${ project . projectName } ` ) ;
706680 project . isDiscovering = true ;
@@ -728,51 +702,18 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
728702 project , // Pass project for access to projectUri and other project-specific data
729703 ) ;
730704
731- // Track which files this project discovered by inspecting created TestItems
732- // This data will be used in Phase 3 for overlap resolution
733- this . trackProjectDiscoveredFiles ( project , discoveryState ) ;
734-
735705 // Mark project as completed
736- discoveryState . projectsCompleted . add ( project . projectId ) ;
706+ projectsCompleted . add ( project . projectId ) ;
737707 traceInfo ( `[test-by-project] Project ${ project . projectName } discovery completed` ) ;
738708 } catch ( error ) {
739709 traceError ( `[test-by-project] Discovery failed for project ${ project . projectName } :` , error ) ;
740710 // Individual project failures don't block others
741- discoveryState . projectsCompleted . add ( project . projectId ) ; // Still mark as completed
711+ projectsCompleted . add ( project . projectId ) ; // Still mark as completed
742712 } finally {
743713 project . isDiscovering = false ;
744714 }
745715 }
746716
747- /**
748- * Tracks which files a project discovered by inspecting its TestItems.
749- * Populates the fileToProjects map for overlap detection in Phase 3.
750- */
751- private trackProjectDiscoveredFiles ( project : ProjectAdapter , discoveryState : WorkspaceDiscoveryState ) : void {
752- // Get all test items for this project from its result resolver
753- const testItems = project . resultResolver . runIdToTestItem ;
754-
755- // Extract unique file paths from test items
756- const filePaths = new Set < string > ( ) ;
757- testItems . forEach ( ( testItem ) => {
758- if ( testItem . uri ) {
759- filePaths . add ( testItem . uri . fsPath ) ;
760- }
761- } ) ;
762-
763- // Track which projects discovered each file
764- filePaths . forEach ( ( filePath ) => {
765- if ( ! discoveryState . fileToProjects . has ( filePath ) ) {
766- discoveryState . fileToProjects . set ( filePath , new Set ( ) ) ;
767- }
768- discoveryState . fileToProjects . get ( filePath ) ! . add ( project ) ;
769- } ) ;
770-
771- traceVerbose (
772- `[test-by-project] Project ${ project . projectName } discovered ${ filePaths . size } file(s) with ${ testItems . size } test(s)` ,
773- ) ;
774- }
775-
776717 /**
777718 * Discovers tests for all workspaces in the workspace folders.
778719 */
0 commit comments