Skip to content

Conversation

Copy link

Copilot AI commented Jan 8, 2026

Previously, test discovery ran once per workspace folder. This fails for monorepos with multiple Python projects, where each project has its own configuration (pyproject.toml, pytest.ini, setup.py).

Changes

Project Detection

  • Uses environment extension's getPythonProjects() API to detect Python projects
  • Queries projects from environment extension when available
  • Falls back to workspace root as single project if environment extension not available or no projects found
  • Filters projects by workspace to only process projects in current workspace

Controller Architecture

  • Changed adapter storage: Map<Uri, WorkspaceTestAdapter>Map<string, ProjectTestAdapter[]>
  • Each workspace maintains multiple project-specific adapters
  • createProjectAdapter() instantiates adapters with project root as working directory

Discovery Flow

// Before: single discovery per workspace
workspace  adapter.discoverTests(workspaceUri)

// After: parallel discovery per project
workspace  envExtApi.getPythonProjects()  [project1, project2, ...] 
          adapter1.discoverTests(project1.uri)
          adapter2.discoverTests(project2.uri)

Test Execution Routing

  • Groups test items by containing project based on file paths
  • Routes each group to its project-specific adapter
  • Supports cross-project test runs in single execution

Example

For a workspace with structure:

/workspace
  ├── service-a/
  │   ├── pyproject.toml
  │   └── tests/
  └── service-b/
      ├── pytest.ini
      └── tests/

Discovery now runs twice (once per project) with correct working directories, instead of once at workspace root with potentially incorrect configuration.

Backward Compatibility

Single-project workspaces behave identically to before. When environment extension is not available, falls back to treating workspace as single project.

Original prompt

implement what is outlined in this doc as: ### Phase 2: Run Discovery Per Project. we have already done phase 1

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@eleanorjboyd
Copy link
Owner

@copilot saw your planning and you don't need: Create Project Root Detection. the environments extension handles detection, you just query the env ext api to get the info. Also lets rely on existing file watchers now, since they already exist for the test updating. If you feel they don't cover it add a todo and we can cirlce back

Copilot AI and others added 2 commits January 8, 2026 22:12
- Created projectRootFinder.ts utility to detect Python project roots
- Updated PythonTestController to support multiple projects per workspace
- Modified discovery flow to detect projects and create adapters for each
- Updated test execution to route tests to correct project adapter

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
- Created comprehensive unit tests for projectRootFinder
- 8/12 tests passing - helper functions working correctly
- Some stub configuration issues with findFiles to be resolved
- Core functionality (isFileInProject, findProjectForTestItem) fully tested

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement phase 2 of project discovery Implement Phase 2: Per-project test discovery for multi-project workspaces Jan 8, 2026
Copilot AI requested a review from eleanorjboyd January 8, 2026 22:21
- Removed custom projectRootFinder.ts utility
- Use environment extension's getPythonProjects() API
- Query projects from env ext when available
- Fall back to workspace as single project if env ext not available
- Maintain per-project adapter architecture for discovery and execution

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 8, 2026

@copilot saw your planning and you don't need: Create Project Root Detection. the environments extension handles detection, you just query the env ext api to get the info. Also lets rely on existing f...

Updated implementation to use the environment extension API instead of custom project detection:

  • Removed projectRootFinder.ts and its tests
  • Now calling envExtApi.getPythonProjects() to get project information
  • Falls back to workspace root when env extension not available or no projects found
  • Existing file watchers retained - they already handle test updates

Commit: 24d8613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants