test: cover registered package manager lifecycles - #1704
test: cover registered package manager lifecycles#1704Eduardo Villalpando Mello (edvilme) wants to merge 13 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480
There was a problem hiding this comment.
Pull request overview
Adds a package-manager-centric integration baseline to exercise install/list/direct-deps/uninstall lifecycles against the live registered package manager instances, establishing behavioral coverage ahead of the package-manager command refactor work.
Changes:
- Adds a fixture registry describing active/deferred package managers and their expected capabilities.
- Reworks the integration test to drive a disposable project + disposable environment lifecycle per active profile, with registry completeness guards and prerequisite-based skips.
- Adds an integration-test-only API bridge (env-gated) to expose the live registered
PackageManagerimplementations, and pins the integration test user profile to normal pip execution (python-envs.alwaysUseUv=false).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/integration/packageManagerFixtures.ts | Introduces fixture definitions for registered package managers, capabilities, and per-manager profiles (active vs deferred). |
| src/test/integration/packageManagement.integration.test.ts | Implements the fixture-driven integration lifecycle tests and registry completeness checks, plus robust cleanup and prerequisite skips. |
| src/internal.api.ts | Adds a registeredManager getter on InternalPackageManager to expose the wrapped live implementation for tests. |
| src/extension.ts | Env-gated integration-test bridge that exposes registered package managers via the exported API object. |
| .vscode-test.mjs | Seeds integration test user settings to force python-envs.alwaysUseUv=false for consistent pip execution during integration runs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/test/integration/packageManagement.integration.test.ts:150
addPythonProjectis a synchronous (void-returning) API, soawaithere is redundant and can confuse readers (and may be flagged by@typescript-eslint/await-thenableif enabled).
await api.addPythonProject(project);
This reverts commit 596583f.
6966031 to
31d186d
Compare
Package manager coverage is being developed separately in PR #1704. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480
…ration-coverage # Conflicts: # api/CHANGELOG.md # api/package-lock.json # api/package.json # src/features/pythonApi.ts
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
| environmentManagerId: CONDA_MANAGER_ID, | ||
| name: 'Conda', | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
profiles hard-codes Pip and Conda without checking the registered package-manager IDs, so Poetry and future managers can silently lack coverage. Encode every registered manager as either an active fixture or an explicit deferral and assert registry completeness.
|
|
||
| await api.managePackages(environment!, { uninstall: ['requests'], runHeadless: true }); | ||
| packages = await api.getPackages(environment!, { skipCache: true }); | ||
| assert.ok(!packages?.some((pkg) => pkg.name === 'requests'), 'Package not uninstalled'); |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
The test first reads packages after installation, so it does not establish that requests was absent or record the claimed uncached baseline. Query with skipCache: true before installation and normalize the starting state before asserting the install transition.
|
GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for src/managers/builtin/pipPackageManager.ts:L85.
A headless manage operation may still display an error prompt if its post-operation package refresh fails through the downstream refresh path. Propagate headless state through that path and add coverage that forces |
| const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; | ||
| assert.ok(workspaceFolder, 'Integration test workspace not found'); | ||
| workspaceUri = workspaceFolder.uri; | ||
| const config = vscode.workspace.getConfiguration('python-envs', workspaceUri); |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
The Pip fixture does not force normal Pip execution, so machines with uv enabled may exercise the uv-backed path rather than the intended normal-Pip lifecycle. Pin the relevant setting for this fixture and restore its prior value during teardown.
| suiteTeardown(async () => { | ||
| try { | ||
| if (environment) { | ||
| await api.removeEnvironment(environment, { runHeadless: true }); |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Conda removal can resolve after a deletion failure, allowing teardown to pass while leaving the disposable environment behind. Propagate removal failures or verify that the environment no longer exists after cleanup.
|
|
||
| await api.refreshEnvironments(workspaceUri); | ||
|
|
||
| environment = await api.createEnvironment(workspaceUri, { quickCreate: true }); |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Both profiles use the same workspace, allowing project and workspace state to leak between manager lifecycles. Create a distinct disposable project scope per profile and clean it up with the environment.
| @@ -1091,6 +1119,14 @@ export interface PythonPackageManagerRegistrationApi { | |||
| } | |||
|
|
|||
| export interface PythonPackageGetterApi { | |||
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Exposing registered manager instances adds a public path around the centralized package-management facade solely for this integration test. Prefer the existing facade or a runtime-gated internal test bridge instead of expanding the public API.
| if (versions === undefined) { | ||
| this.skip(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
Treating every undefined version result as a prerequisite skip can hide command, parsing, or network regressions because managers also map those failures to undefined. Gate known prerequisites before invoking the operation, then fail when an available manager unexpectedly cannot return versions.
|
The sample API contract should also mirror |
Stella Huang (StellaHuang95)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Summary
Adds a package-manager-centric integration baseline that intentionally precedes and de-risks #1686, so the package-manager command refactor is exercised against behavior established on
main.inspect()snapshots and performs guarded failure-safe cleanupmain, while available-version lookup would also introduceuv tool run pipnetwork seedingValidation
npm run compilenpm run compile-testsnpm run lintnpm run unittestpackageManagement.integration.test.js: 3 passing, 2 prerequisite skips locallyThe active Pip and Conda fixtures require package-index/network access when their runtime prerequisites are present.
Fixes #1701