Repository navigation
Description
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-lockfilecannot be verified against the CLI behavior it affects without runningadd,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.
- 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.
- 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.
- 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 inpnpm/AGENTS.md: every separate test binary statically links the whole dependency graph,pnprincluded, 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. - 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.
- Break the
pnpm-testing-utilstopnprdev-dependency edge, for example by feature-gating the registry mock behind the crates that need it. Apnprchange 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
chore: run the tests a change affects, with smoke tests for its depen…
chore: run the tests a change affects, with smoke tests for its depen…
kairosci commentedon Nov 24, 2026
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-utilsharness intopnpm-testing-utils-registry, so a core crate no longer reachespnprthrough dev-dependencies. A staticcargo metadatareverse-dependency count forpnpm-lockfilefell from 88 packages and 95.0% of counted test attributes to 43 packages and 77.1%. The same measurement putspnpm-configat 68.8%,pnpm-cargo-resolverat 53.8%, andpnpr-storageat 55.2%. Both harness crates are now workspace-wide changes intest-affected.The PR also adds the crate-to-module map for CLI end-to-end coverage. For
pnpm-lockfilethat 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-changesskill,pnpm/CONTRIBUTING.md, andpnpm/AGENTS.mdnow describe that selection story. The issue is left open for the PR to close on merge.perf(test): scope end-to-end coverage for core crates
perf(test): narrow core-crate test selection (pnpm#18407)