Skip to content

pacquet: the CLI end-to-end test target makes partial test runs select almost the whole suite #18

Done
pnpm/pnpm
#18407

Description

@zkochan

Problem

Selecting a subset of the Rust test suite for a given change barely reduces what runs. Any crate near the core of the workspace pulls in almost the whole suite, so the practical choice today is "the changed crate's own tests" (too little) or "everything" (an hour of machine time).

The workspace has 109 crates and roughly 11,500 test attributes (#[test], #[tokio::test], #[rstest]; the real test count is higher because rstest cases expand). pnpm-cli holds 3,712 of them, 2,201 in the end-to-end suite under crates/cli/tests/suite/, and it depends on nearly every other crate. It is also where most of the wall-clock time goes, because those tests spawn processes and a registry.

That single crate is what makes dependency-based selection useless. Measured with cargo nextest's rdeps() predicate, which selects a crate plus everything that transitively depends on it:

Changed crate Share of the suite rdeps() selects
pnpm-fs 93%
pnpm-lockfile 88%
pnpm-config 84%
pnpm-cargo-resolver 84%
pnpr-storage 84%

A second edge makes it worse across products: pnpm-testing-utils is a dev-dependency of most crates and itself depends on pnpr. Through normal dependency edges alone, a change to pnpr-storage reaches 6% of the suite. With dev-dependency edges it reaches 84%, because the whole pacquet CLI suite is now downstream of it.

The e2e tests are also invisible to any static analysis that might prune them: they exercise the CLI as a spawned subprocess, so there is no call edge from a test to the code it covers. Selection below crate granularity cannot help there, whatever tooling is used.

Why it matters

  • Local iteration. just test-affected (chore: run the tests a change affects, with smoke tests for its dependents pnpm#14985) maps a diff to crates and runs their tests. For a core crate it can only offer the crate's own tests, because anything wider is the full suite.
  • CI. Per-PR job scoping is not worth building while the selection for a typical change is 85% of the suite.
  • Feedback time. A change to pnpm-lockfile cannot be verified against the CLI behavior it affects without running add, dlx, publish, and every other unrelated e2e module.

This is not a case of having too many e2e tests

Worth stating up front, because "move them to a lower level" is the obvious first reaction and is mostly wrong here. What the suite asserts:

Assertion kind Occurrences
stdout / stderr 1053
filesystem reads 1006
path existence 538
symlink checks 369
insta snapshots 7

That is a suite asserting filesystem end-state and CLI output, which is pnpm's actual contract. A unit test on a resolver cannot catch a wrong node_modules layout, a missing bin shim, or a symlink that behaves differently on Windows. The tests ported from the upstream TypeScript suite under plans/TEST_PORTING.md land here deliberately, one for one, because that correspondence is what makes v11 parity auditable.

The problem is the shape of the target, not the number of tests in it.

Possible directions

Not a settled design. Ordered by what should happen first, not by size of change.

  1. Measure where the time goes before restructuring anything. CI already stages per-test durations to Bencher on every run. Ranking the e2e tests by duration turns every guess below into a number. Of 210 suite files, 123 use the mocked registry and 87 do not; the 942 tests in registry-free files are cheap already, so the cost is concentrated in the roughly 1,259 tests that perform real installs.
  2. Check harness cost before test placement. Mocked-registry tests each hold a per-test store. If setup dominates the wall clock, sharing a store or registry across a module cuts the cost without moving a single assertion, and without trading away any coverage.
  3. Split crates/cli/tests/suite/ into several test targets grouped by area (install and resolution, publish and auth, run and exec, workspace, ecosystem integrations). This is what makes selection mean something. It is in tension with a constraint already documented in pnpm/AGENTS.md: every separate test binary statically links the whole dependency graph, pnpr included, at roughly 240 MB of link output each. Splitting into N targets multiplies that cost on every change to the crate, so the tradeoff needs measuring: link time and disk against selectivity.
  4. Move a measured subset of tests down, not the suite. The candidates are tests that pay for a full install to assert a decision (which version was chosen, what the lockfile records, how a spec parsed) rather than an effect (layout, symlinks, shims). A decision belongs in the crate that makes it, where it runs in milliseconds and fails closer to the cause. Tests ported for v11 parity stay where they are. Every test moved below the process boundary also becomes visible to dependency-based selection, so this shrinks the blob and makes the remainder selectable.
  5. Break the pnpm-testing-utils to pnpr dev-dependency edge, for example by feature-gating the registry mock behind the crates that need it. A pnpr change would then stop selecting pacquet's tests.

Acceptance

A change to a core crate such as pnpm-lockfile selects a materially smaller share of the suite than it does today, with a number to show for it. Update the testing-changes skill and pnpm/CONTRIBUTING.md with whatever the new selection story is.


Written by an agent (Claude Code, claude-opus-5[1m]).

Activity

  1. transferred this issue frompnpm/pnpmon Sep 26, 2026
  2. kairosci commented on Nov 24, 2026

    @kairosci

    Update

    pnpm/pnpm#18407 now covers the whole issue, not just the default affected-test workflow.

    It moves registry-backed helpers out of the shared pnpm-testing-utils harness into pnpm-testing-utils-registry, so a core crate no longer reaches pnpr through dev-dependencies. A static cargo metadata reverse-dependency count for pnpm-lockfile fell from 88 packages and 95.0% of counted test attributes to 43 packages and 77.1%. The same measurement puts pnpm-config at 68.8%, pnpm-cargo-resolver at 53.8%, and pnpr-storage at 55.2%. Both harness crates are now workspace-wide changes in test-affected.

    The PR also adds the crate-to-module map for CLI end-to-end coverage. For pnpm-lockfile that selects 503 of 4,696 end-to-end test attributes, and about 5.5% of workspace test attributes including its own tests and smoke.

    The testing-changes skill, pnpm/CONTRIBUTING.md, and pnpm/AGENTS.md now describe that selection story. The issue is left open for the PR to close on merge.

  3. added a commit that references this issue on Nov 25, 2026
    17629a9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions