Skip to content

Conversation

@eleanorjboyd
Copy link
Member

Adds infrastructure to support multiple Python projects (each with distinct Python executables and test configurations) within a single VS Code workspace. Currently behind a feature flag (useProjectBasedTesting = false) for safe deployment.

Core Infrastructure

  • ProjectAdapter interface: Encapsulates project identity, Python environment, test adapters, and discovery state
  • Project-scoped test IDs: Format {projectId}::{testPath} prevents ID collisions between projects
  • Utility functions: Project ID generation via hash, nested project detection, ID scoping/parsing
  • WorkspaceDiscoveryState: Temporary state for overlap detection and ownership resolution during discovery

Result Resolver Updates

  • Added optional projectId parameter to PythonResultResolver constructor
  • When present, prefixes all test IDs with project scope; when absent, uses legacy IDs (backward compatible)
  • Updated populateTestTree() and TestDiscoveryHandler to propagate project scoping

Project Discovery Integration

  • discoverWorkspaceProjects(): Queries Python Environment API for projects, filters to workspace, creates ProjectAdapter instances
  • createProjectAdapter(): Resolves Python environment, creates project-scoped resolver and provider-specific adapters
  • createDefaultProject(): Fallback that mimics single-workspace behavior using workspace interpreter
  • State tracking maps:
    • workspaceProjects: Project registry by workspace URI
    • vsIdToProject: O(1) test-to-project lookup for execution
    • fileUriToProject: File-to-project mapping for file watching
    • projectToVsIds: Project-to-tests mapping for cleanup

Activation Flow

public async activate(): Promise<void> {
    if (this.useProjectBasedTesting) {
        // New: Discover projects via Python Environment API
        const projects = await this.discoverWorkspaceProjects(workspace.uri);
        this.workspaceProjects.set(workspace.uri, projectsMap);
    } else {
        // Legacy: Single WorkspaceTestAdapter per workspace
        this.activateLegacyWorkspace(workspace);
    }
}

Graceful degradation: Any failure in project discovery automatically falls back to legacy single-workspace mode. All new code paths are disabled by default until Phases 3-4 (discovery with overlap resolution, test execution) are implemented.

Files Changed

New:

  • testController/common/projectAdapter.ts - Type definitions
  • testController/common/projectUtils.ts - Utilities

Modified:

  • testController/controller.ts - Project discovery and state management
  • testController/common/resultResolver.ts - Project scoping support
  • testController/common/testDiscoveryHandler.ts - Scoped error nodes
  • testController/common/utils.ts - Scoped test ID creation

eleanorjboyd and others added 5 commits January 8, 2026 11:02
- Created ProjectAdapter and WorkspaceDiscoveryState interfaces
- Added project utility functions (ID generation, scoping, nested project detection)
- Updated PythonResultResolver to support optional projectId parameter
- Modified populateTestTree to create project-scoped test IDs
- Updated TestDiscoveryHandler to handle project-scoped error nodes

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
- Added project-based state maps (workspaceProjects, vsIdToProject, fileUriToProject, projectToVsIds)
- Implemented discoverWorkspaceProjects() to query Python Environment API
- Created createProjectAdapter() to build ProjectAdapter from PythonProject
- Added createDefaultProject() for backward compatibility
- Imported necessary types from environment API
- Added flag to enable/disable project-based testing

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
- Modified activate() to check useProjectBasedTesting flag
- Calls discoverWorkspaceProjects() for each workspace when enabled
- Populates workspaceProjects map with discovered projects
- Created activateLegacyWorkspace() for backward compatibility
- Falls back to legacy mode if project discovery fails
- Maintains full backward compatibility with flag disabled

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
@eleanorjboyd eleanorjboyd self-assigned this Jan 8, 2026
@eleanorjboyd eleanorjboyd added debt Covers everything internal: CI, testing, refactoring of the codebase, etc. skip-issue-check labels Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Covers everything internal: CI, testing, refactoring of the codebase, etc. skip-issue-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant