Skip to content

test: cover registered package manager lifecycles - #1704

Open
Eduardo Villalpando Mello (edvilme) wants to merge 13 commits into
mainfrom
package-manager-integration-coverage
Open

test: cover registered package manager lifecycles#1704
Eduardo Villalpando Mello (edvilme) wants to merge 13 commits into
mainfrom
package-manager-integration-coverage

Conversation

@edvilme

Copy link
Copy Markdown
Contributor

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.

  • drives one stateful install/list/direct-package/uninstall lifecycle per active profile
  • uses unique disposable projects and manager-owned disposable environments
  • exercises the live registered manager instances through a runtime-gated integration-test bridge
  • guards registry completeness so every registered package-manager ID has an active fixture or explicit deferral
  • covers normal Pip execution and Conda when their runtime prerequisites are available
  • records an uncached baseline instead of assuming a newly created environment is empty
  • restores workspace-scoped configuration from inspect() snapshots and performs guarded failure-safe cleanup
  • defers Poetry pending a Poetry-owned project/lockfile lifecycle
  • defers uv-backed Pip because changing the machine-scoped selection reliably within one extension host was not stable on main, while available-version lookup would also introduce uv tool run pip network seeding
  • pins the disposable integration-test user profile to normal Pip execution

Validation

  • npm run compile
  • npm run compile-tests
  • npm run lint
  • npm run unittest
  • targeted packageManagement.integration.test.js: 3 passing, 2 prerequisite skips locally
    • Pip skipped because quick create selected Python 3.15.0 alpha, whose bundled Pip metadata is incomplete
    • Conda skipped because Conda is not installed
  • reviewer specialist: clean, no Critical or Important findings

The active Pip and Conda fixtures require package-index/network access when their runtime prerequisites are present.

Fixes #1701

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PackageManager implementations, 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.

Comment thread src/test/integration/packageManagement.integration.test.ts Outdated
Comment thread src/test/integration/packageManagement.integration.test.ts Outdated
Comment thread src/test/integration/packageManagement.integration.test.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6b2fe9b5-38ea-442f-b07a-b6c71134d480

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • addPythonProject is a synchronous (void-returning) API, so await here is redundant and can confuse readers (and may be flagged by @typescript-eslint/await-thenable if enabled).
        await api.addPythonProject(project);

@edvilme
Eduardo Villalpando Mello (edvilme) force-pushed the package-manager-integration-coverage branch from 6966031 to 31d186d Compare August 12, 2026 20:46
Eduardo Villalpando Mello (edvilme) added a commit that referenced this pull request Aug 12, 2026
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
@StellaHuang95

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR.

environmentManagerId: CONDA_MANAGER_ID,
name: 'Conda',
},
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@StellaHuang95

Copy link
Copy Markdown
Contributor

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.

Warning · Non-blocking recommendation

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 pip list to fail.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/api.ts
@@ -1091,6 +1119,14 @@ export interface PythonPackageManagerRegistrationApi {
}

export interface PythonPackageGetterApi {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@StellaHuang95

Copy link
Copy Markdown
Contributor

The sample API contract should also mirror PackageManagementInteractionOptions.runHeadless and PythonPackageGetterApi.getPackageManager from src/api.ts so consumer-facing contracts do not drift.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@StellaHuang95 Stella Huang (StellaHuang95) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-package debt Code quality issues review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add package-manager integration lifecycle coverage

3 participants