test: replace @pnpm/registry-mock with an in-repo in-process registry (#11927)

Replace the external `@pnpm/registry-mock` (Verdaccio) test dependency with an in-repo, in-process registry that serves package fixtures to **both** the pacquet Rust tests and the pnpm CLI (Jest) tests. No separately managed registry process is needed.

### How it works

- **Fixtures** live at `registry/.fixtures/packages/<name>/<version>/…`, moved verbatim from [`pnpm/registry-mock`](https://github.com/pnpm/registry-mock) (keyed by each `package.json`'s `name`+`version`).
- **`pnpm-registry-fixtures`** builds verdaccio-shaped storage from those fixtures; the in-tree **`pnpm-registry`** crate serves it.
  - Files whose names differ only by case (`@pnpm.e2e/with-same-file-in-different-cases`) and `bundleDependencies` trees are composed **in memory** by the builder, since neither can be committed to the working tree.
- **pacquet**: `pacquet-testing-utils`' `TestRegistry` starts the server lazily (once per process) in proxy mode, serving `@pnpm.e2e` fixtures locally and falling through to the npm uplink for real packages (`is-positive`, `is-negative`, …) — matching how registry-mock behaved.
- **pnpm CLI**: the `with-registry` Jest `globalSetup` builds storage from the fixtures via the new `pnpm-registry-prepare` binary (built from source in the Test CI job) and serves it with `pnpm-registry`. `REGISTRY_MOCK_PORT` / `REGISTRY_MOCK_CREDENTIALS` / `getIntegrity` now come from `@pnpm/testing.registry-mock`.

### Result

`@pnpm/registry-mock` is removed from every manifest, the catalog, and `packageExtensions`; `cargo test` / `cargo nextest run` / `just test` and the pnpm CLI Jest suites all run registry-backed tests without launching Verdaccio.
This commit is contained in:
Marvin Hagemeister authored and GitHub committed 2026-05-29 14:35:45 +02:00
1 parent 1e9ab2935f
commit 49e6074644
493 files changed
+3685 -1166

No files matched your search

-4
View File
@@ -110,8 +110,6 @@ jobs:
- name: Test
shell: bash
run: |
just registry-mock launch
# removing env vars is a temporary workaround for unit tests in pacquet relying on external environment
# this should be removed in the future
unset PNPM_HOME
@@ -119,8 +117,6 @@ jobs:
just test
just registry-mock end
doc:
name: Doc
runs-on: ubuntu-latest
-4
View File
@@ -75,8 +75,6 @@ jobs:
- name: Run
run: |
just registry-mock launch
# removing env vars is a temporary workaround for unit tests in pacquet relying on external environment
# this should be removed in the future
unset PNPM_HOME
@@ -84,8 +82,6 @@ jobs:
cargo codecov --lcov --output-path lcov.info
just registry-mock end
- name: Upload Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
+15
View File
@@ -69,6 +69,21 @@ jobs:
name: compiled-packages
- name: Extract compiled artifacts
run: tar -xzf compiled.tar.gz
# The test harness serves package fixtures through the in-repo
# `pnpm-registry`; `pnpm-registry-prepare` turns the raw fixtures under
# `registry/.fixtures/packages` into the storage the server reads.
- name: Install Rust
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: registry-prepare
- name: Build the registry fixture preparer
shell: bash
run: |
cargo build --locked --release -p pnpm-registry-fixtures --bin pnpm-registry-prepare
bin="$PWD/target/release/pnpm-registry-prepare"
[ -f "$bin.exe" ] && bin="$bin.exe"
echo "PNPM_REGISTRY_PREPARE_BIN=$bin" >> "$GITHUB_ENV"
- name: Determine test scope
id: test-scope
shell: bash
+4
View File
@@ -61,3 +61,7 @@ __fixtures__/custom-modules-dir/patches/
/target
/bench-work-env
.pacquet
## test registry auth state (written by pnpm-registry when serving with auth)
htpasswd
tokens.db
+1 -1
View File
@@ -1,4 +1,4 @@
include = ["Cargo.toml", "pacquet/crates/*/*.toml", "pacquet/tasks/*/*.toml"]
include = ["Cargo.toml", "pacquet/crates/*/*.toml", "pacquet/tasks/*/*.toml", "registry/crates/*/*.toml"]
[formatting]
align_entries = true
Generated
+19 -2
View File
@@ -899,6 +899,7 @@ version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
dependencies = [
"crc32fast",
"miniz_oxide",
"zlib-rs",
]
@@ -2577,7 +2578,6 @@ dependencies = [
"pacquet-patching",
"pacquet-real-hoist",
"pacquet-registry",
"pacquet-registry-mock",
"pacquet-reporter",
"pacquet-resolving-default-resolver",
"pacquet-resolving-deps-resolver",
@@ -2677,6 +2677,7 @@ dependencies = [
"clap",
"home",
"pipe-trait",
"pnpm-registry-fixtures",
"reqwest",
"serde",
"serde_json",
@@ -2908,9 +2909,11 @@ dependencies = [
"assert_cmd",
"command-extra",
"junction",
"pacquet-registry-mock",
"pnpm-registry",
"pnpm-registry-fixtures",
"tempfile",
"text-block-macros",
"tokio",
"walkdir",
]
@@ -3086,6 +3089,20 @@ dependencies = [
"wax",
]
[[package]]
name = "pnpm-registry-fixtures"
version = "0.0.1"
dependencies = [
"base64 0.22.1",
"clap",
"flate2",
"node-semver",
"serde_json",
"sha2",
"tar",
"walkdir",
]
[[package]]
name = "pori"
version = "0.0.0"
+4 -1
View File
@@ -70,7 +70,8 @@ pacquet-workspace-state = { path = "pacquet/crates/workspace-s
pacquet-registry-mock = { path = "pacquet/tasks/registry-mock" }
# Registry (sibling project — pnpm-compatible registry server)
pnpm-registry = { path = "registry/crates/pnpm-registry", version = "0.0.1" }
pnpm-registry = { path = "registry/crates/pnpm-registry", version = "0.0.1" }
pnpm-registry-fixtures = { path = "registry/crates/pnpm-registry-fixtures", version = "0.0.1" }
# Dependencies
async-recursion = { version = "1.1.1" }
@@ -85,6 +86,7 @@ clap = { version = "4", features = ["derive", "string"] }
command-extra = { version = "1.0.0" }
base64 = { version = "0.22.1" }
bcrypt = { version = "0.17.1" }
bytes = { version = "1.11.0" }
chrono = { version = "0.4.44", default-features = false, features = ["clock"] }
dashmap = { version = "6.1.0" }
derive_more = { version = "2.1.1", features = ["full"] }
@@ -97,6 +99,7 @@ indexmap = { version = "2.14.0", features = ["serde"] }
insta = { version = "1.47.2", features = ["yaml", "glob", "walkdir"] }
itertools = { version = "0.14.0" }
futures-util = { version = "0.3.32" }
flate2 = { version = "1.1.9" }
gethostname = { version = "1" }
getrandom = { version = "0.3.4" }
miette = { version = "7.6.0", features = ["fancy"] }
+1 -1
View File
@@ -50,7 +50,7 @@
"@pnpm/constants": "workspace:*",
"@pnpm/installing.modules-yaml": "workspace:*",
"@pnpm/lockfile.types": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/types": "workspace:*",
"is-windows": "catalog:",
"isexe": "catalog:",
+1 -1
View File
@@ -8,7 +8,7 @@ import { assertStore } from '@pnpm/assert-store'
import { WANTED_LOCKFILE } from '@pnpm/constants'
import type { Modules } from '@pnpm/installing.modules-yaml'
import type { LockfileFile } from '@pnpm/lockfile.types'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import yaml from 'js-yaml'
import { readYamlFileSync } from 'read-yaml-file'
import { writePackageSync } from 'write-package'
+3
View File
@@ -21,6 +21,9 @@
{
"path": "../../lockfile/types"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../assert-store"
}
+2 -2
View File
@@ -33,9 +33,9 @@
},
"dependencies": {
"@jest/globals": "catalog:",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store.cafs": "workspace:*",
"@pnpm/store.index": "workspace:*"
"@pnpm/store.index": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*"
},
"devDependencies": {
"@pnpm/assert-store": "workspace:*",
+1 -1
View File
@@ -2,8 +2,8 @@ import fs from 'node:fs'
import path from 'node:path'
import { expect } from '@jest/globals'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
export interface StoreAssertions {
getPkgIndexFilePath: (pkgName: string, version: string) => string
+3
View File
@@ -17,6 +17,9 @@
},
{
"path": "../../store/index"
},
{
"path": "../../testing/registry-mock"
}
]
}
-2
View File
@@ -8,12 +8,10 @@
"@babel/core": "catalog:",
"@babel/plugin-transform-explicit-resource-management": "catalog:",
"@pnpm/pnpr": "catalog:",
"@pnpm/registry-mock": "catalog:",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/worker": "workspace:*",
"amaro": "catalog:",
"get-port": "catalog:",
"read-yaml-file": "catalog:",
"tree-kill": "catalog:"
},
"devDependencies": {
@@ -1,32 +1,34 @@
import { spawn } from 'node:child_process'
import { spawn, spawnSync } from 'node:child_process'
import { existsSync, mkdtempSync } from 'node:fs'
import { createRequire } from 'node:module'
import { tmpdir } from 'node:os'
import path from 'node:path'
import { scheduler } from 'node:timers/promises'
import { promisify } from 'node:util'
import getPort from 'get-port'
import { readYamlFileSync } from 'read-yaml-file'
import treeKill from 'tree-kill'
const kill = promisify(treeKill)
const require = createRequire(import.meta.url)
const REPO_ROOT = path.join(import.meta.dirname, '..', '..', '..')
const FIXTURE_PACKAGES = path.join(REPO_ROOT, 'registry', '.fixtures', 'packages')
export default async () => {
if (!process.env.PNPM_REGISTRY_MOCK_PORT) {
process.env.PNPM_REGISTRY_MOCK_PORT = (await getPort({ from: 7700, to: 7800 })).toString()
}
// We still call `prepare()` from `@pnpm/registry-mock`: it copies
// the read-only fixture `storage-cache` into a tempy directory
// and writes `registry/runtime-config-${port}.yaml` with the
// tempy path under `storage:`. That yaml is what
// `locations.storage()` reads when `getIntegrity` (also from
// registry-mock) is called from tests. We just don't launch
// verdaccio against it — we launch pnpm-registry instead.
const { prepare, REGISTRY_MOCK_CREDENTIALS } = await import('@pnpm/registry-mock')
const { addUser } = await import('@pnpm/testing.registry-mock')
prepare()
const { addUser, REGISTRY_MOCK_CREDENTIALS } = await import('@pnpm/testing.registry-mock')
// Build verdaccio-shaped storage from the in-repo package fixtures. The
// registry mutates this storage during tests (publishes, dist-tags), so it
// gets its own writable copy in a temp dir, never the read-only fixtures.
const storage = mkdtempSync(path.join(tmpdir(), 'pnpm-registry-mock-storage-'))
buildStorage(storage)
process.env.PNPM_REGISTRY_MOCK_STORAGE = storage
const storage = readStoragePath(process.env.PNPM_REGISTRY_MOCK_PORT)
const bin = resolvePnpmRegistryBin()
const server = spawn(
@@ -34,11 +36,9 @@ export default async () => {
[
'--listen', `127.0.0.1:${process.env.PNPM_REGISTRY_MOCK_PORT}`,
'--storage', storage,
'--upstream', process.env.PNPM_REGISTRY_MOCK_UPLINK ?? 'https://registry.npmjs.org',
'--public-url', `http://localhost:${process.env.PNPM_REGISTRY_MOCK_PORT}`,
// Match registry-mock's verdaccio config: a one-year TTL so
// the fixture packuments (mtime: whenever the npm tarball was
// built) never look stale and never trigger a re-fetch to
// A one-year TTL so the fixture packuments (whose `time` values are
// static) never look stale and never trigger a re-fetch to
// npmjs.org that would 404.
'--packument-ttl-secs', '31536000',
],
@@ -72,36 +72,44 @@ export default async () => {
}
/**
* Read the `storage:` path that `@pnpm/registry-mock`'s `prepare()`
* just wrote into the runtime-config yaml. We can't import
* `locations.storage` from the registry-mock package — it isn't
* re-exported from its `index.ts` — but the file path is stable.
* Build registry storage from the in-repo fixtures into `out` using the
* `pnpm-registry-prepare` binary (built from the `pnpm-registry-fixtures`
* crate). The same builder backs pacquet's in-process registry.
*/
function readStoragePath (port) {
const configPath = require.resolve(
`@pnpm/registry-mock/registry/runtime-config-${port}.yaml`
)
const { storage } = readYamlFileSync(configPath)
return storage
function buildStorage (out) {
const bin = resolvePnpmRegistryPrepareBin()
const result = spawnSync(bin, ['--packages', FIXTURE_PACKAGES, '--out', out], { stdio: 'inherit' })
if (result.status !== 0) {
throw new Error(
`pnpm-registry-prepare failed to build fixture storage (exit ${result.status ?? result.signal}).`
)
}
}
/**
* Locate the `pnpm-registry` binary. Lookup order:
* Locate the `pnpm-registry-prepare` binary. Lookup order:
*
* 1. `PNPM_REGISTRY_BIN` env var override (escape hatch for local
* Rust work — point it at `target/release/pnpm-registry` to test
* in-progress changes to the registry crate).
* 2. The platform binary that `pnpm install` pulled in as an
* optionalDependency of `@pnpm/pnpr` — i.e.
* `@pnpm/pnpr.<platform>-<arch>/pnpr[.exe]`. The resolution goes
* through the `@pnpm/pnpr` wrapper's path because the platform
* sub-package lives in the wrapper's own `node_modules`, not
* anywhere on the parent chain of this file.
* 1. `PNPM_REGISTRY_PREPARE_BIN` env var (set by CI, which builds it from source).
* 2. A locally-built `target/{release,debug}/pnpm-registry-prepare`.
*/
function resolvePnpmRegistryPrepareBin () {
return resolveRustBin('pnpm-registry-prepare', 'PNPM_REGISTRY_PREPARE_BIN')
}
/**
* Locate the `pnpm-registry` server binary. Lookup order:
*
* 1. `PNPM_REGISTRY_BIN` env var override.
* 2. A locally-built `target/{release,debug}/pnpm-registry`.
* 3. The platform binary shipped as an optionalDependency of `@pnpm/pnpr`.
*/
function resolvePnpmRegistryBin () {
if (process.env.PNPM_REGISTRY_BIN) {
return process.env.PNPM_REGISTRY_BIN
}
const localBin = findRustTargetBin('pnpm-registry')
if (localBin) return localBin
const ext = process.platform === 'win32' ? '.exe' : ''
const platformPkg = `@pnpm/pnpr.${process.platform}-${process.arch}`
try {
@@ -109,14 +117,33 @@ function resolvePnpmRegistryBin () {
return wrapperRequire.resolve(`${platformPkg}/pnpr${ext}`)
} catch {
throw new Error(
`pnpm-registry binary not found. The test suite expects ${platformPkg} ` +
'to be installed (it ships as an optionalDependency of @pnpm/pnpr — ' +
'run `pnpm install` at the repo root to pull it in), or set ' +
'PNPM_REGISTRY_BIN to an absolute path to a locally-built binary.'
'pnpm-registry binary not found. Build it with `cargo build -p pnpm-registry`, ' +
`set PNPM_REGISTRY_BIN, or install ${platformPkg} (an optionalDependency of @pnpm/pnpr).`
)
}
}
function resolveRustBin (name, envVar) {
if (process.env[envVar]) {
return process.env[envVar]
}
const localBin = findRustTargetBin(name)
if (localBin) return localBin
throw new Error(
`${name} binary not found. Build it with \`cargo build -p pnpm-registry-fixtures --bin ${name}\` ` +
`or set ${envVar} to an absolute path.`
)
}
function findRustTargetBin (name) {
const ext = process.platform === 'win32' ? '.exe' : ''
for (const profile of ['release', 'debug']) {
const candidate = path.join(REPO_ROOT, 'target', profile, `${name}${ext}`)
if (existsSync(candidate)) return candidate
}
return undefined
}
const UNUSUAL_REGISTRY_STARTUP_THRESHOLD = 15 // seconds
async function waitForServerOnline () {
@@ -153,4 +180,3 @@ function *exponentialBackoff (attempts = 15, base = 1.5, initialWait = 100) {
yield initialWait * Math.pow(base, i)
}
}
+1 -1
View File
@@ -52,7 +52,7 @@
"@jest/globals": "catalog:",
"@pnpm/agent.client": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/testing.registry-mock": "workspace:*",
"cross-env": "catalog:",
"pnpm-agent": "workspace:*"
},
+1 -1
View File
@@ -7,8 +7,8 @@ import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'
// First run downloads packages from registry-mock — slow on Windows CI
jest.setTimeout(600_000)
import { fetchFromPnpmRegistry } from '@pnpm/agent.client'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { StoreIndex } from '@pnpm/store.index'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { DepPath, ProjectId } from '@pnpm/types'
import { createRegistryServer } from 'pnpm-agent'
+3
View File
@@ -36,6 +36,9 @@
{
"path": "../../store/index"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../client"
}
+1 -1
View File
@@ -64,12 +64,12 @@
"@pnpm/crypto.object-hasher": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store.cafs": "workspace:*",
"@pnpm/store.index": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/test-ipc-server": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/workspace.projects-filter": "workspace:*",
"@types/ramda": "catalog:",
"execa": "catalog:",
+1 -1
View File
@@ -7,10 +7,10 @@ import { rebuild } from '@pnpm/building.commands'
import { ENGINE_NAME, STORE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
import { hashObject } from '@pnpm/crypto.object-hasher'
import { prepare } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import type { PackageFilesIndex } from '@pnpm/store.cafs'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { fixtures } from '@pnpm/test-fixtures'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { safeExeca as execa } from 'execa'
import { DEFAULT_OPTS } from './utils/index.js'
@@ -7,7 +7,7 @@ import { getConfig } from '@pnpm/config.reader'
import { readModulesManifest } from '@pnpm/installing.modules-yaml'
import { prepare } from '@pnpm/prepare'
import { tempDir } from '@pnpm/prepare-temp-dir'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { safeExeca as execa } from 'execa'
import { omit } from 'ramda'
import { readYamlFileSync } from 'read-yaml-file'
+3
View File
@@ -75,6 +75,9 @@
{
"path": "../../testing/command-defaults"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../../workspace/projects-filter"
},
+1 -1
View File
@@ -49,7 +49,7 @@
"@pnpm/cache.commands": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/testing.registry-mock": "workspace:*",
"@types/ramda": "catalog:",
"@zkochan/rimraf": "catalog:",
"execa": "catalog:"
+1 -1
View File
@@ -3,7 +3,7 @@ import path from 'node:path'
import { beforeEach, describe, expect, test } from '@jest/globals'
import { cache } from '@pnpm/cache.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { safeExeca as execa } from 'execa'
+1 -1
View File
@@ -3,7 +3,7 @@ import path from 'node:path'
import { beforeAll, describe, expect, test } from '@jest/globals'
import { cache } from '@pnpm/cache.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { safeExeca as execa } from 'execa'
+1 -1
View File
@@ -3,7 +3,7 @@ import path from 'node:path'
import { beforeEach, describe, expect, test } from '@jest/globals'
import { cache } from '@pnpm/cache.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { safeExeca as execa } from 'execa'
+3
View File
@@ -30,6 +30,9 @@
{
"path": "../../store/path"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../api"
}
-1
View File
@@ -76,7 +76,6 @@
"@pnpm/logger": "workspace:*",
"@pnpm/pkg-manifest.reader": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/testing.mock-agent": "workspace:*",
-1
View File
@@ -72,7 +72,6 @@
"@pnpm/deps.inspection.commands": "workspace:*",
"@pnpm/installing.commands": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
+1 -1
View File
@@ -4,7 +4,7 @@ import path from 'node:path'
import { expect, jest, test } from '@jest/globals'
import type { Config, ConfigContext } from '@pnpm/config.reader'
import { tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
const mockOpen = jest.fn()
jest.unstable_mockModule('open', () => ({
+1 -1
View File
@@ -1,6 +1,6 @@
import { expect, jest, test } from '@jest/globals'
import type { Config, ConfigContext } from '@pnpm/config.reader'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
const mockOpen = jest.fn()
jest.unstable_mockModule('open', () => ({
+1 -1
View File
@@ -6,7 +6,7 @@ import { expect, test } from '@jest/globals'
import { why } from '@pnpm/deps.inspection.commands'
import type { PnpmError } from '@pnpm/error'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { safeExeca as execa } from 'execa'
const pnpmBin = path.join(import.meta.dirname, '../../../../../pnpm/bin/pnpm.mjs')
+1 -1
View File
@@ -8,8 +8,8 @@ import { WANTED_LOCKFILE } from '@pnpm/constants'
import { outdated } from '@pnpm/deps.inspection.commands'
import type { PnpmError } from '@pnpm/error'
import { prepare, tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { symlinkDirSync } from 'symlink-dir'
const f = fixtures(import.meta.dirname)
@@ -6,8 +6,8 @@ import { stripVTControlCharacters as stripAnsi } from 'node:util'
import { expect, test } from '@jest/globals'
import { outdated } from '@pnpm/deps.inspection.commands'
import { tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
const f = fixtures(import.meta.dirname)
const hasOutdatedDepsFixture = f.find('has-outdated-deps')
+1 -1
View File
@@ -4,7 +4,7 @@ import path from 'node:path'
import { expect, jest, test } from '@jest/globals'
import type { Config, ConfigContext } from '@pnpm/config.reader'
import { tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
const mockOpen = jest.fn()
jest.unstable_mockModule('open', () => ({
+1 -1
View File
@@ -1,7 +1,7 @@
import { expect, test } from '@jest/globals'
import type { Config, ConfigContext } from '@pnpm/config.reader'
import { view } from '@pnpm/deps.inspection.commands'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
-1
View File
@@ -81,7 +81,6 @@
"@pnpm/exec.commands": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/test-ipc-server": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/workspace.projects-filter": "workspace:*",
-1
View File
@@ -103,7 +103,6 @@
"@pnpm/installing.modules-yaml": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store.index": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/test-ipc-server": "workspace:*",
+1 -1
View File
@@ -5,7 +5,7 @@ import { describe, expect, test } from '@jest/globals'
import type { PnpmError } from '@pnpm/error'
import { add, remove } from '@pnpm/installing.commands'
import { prepare, prepareEmpty, preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { ProjectManifest } from '@pnpm/types'
import { loadJsonFile } from 'load-json-file'
import { temporaryDirectory } from 'tempy'
+1 -1
View File
@@ -5,9 +5,9 @@ import { expect, test } from '@jest/globals'
import { STORE_VERSION } from '@pnpm/constants'
import { fetch, install } from '@pnpm/installing.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { closeAllStoreIndexes } from '@pnpm/store.index'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { finishWorkers } from '@pnpm/worker'
import { rimrafSync } from '@zkochan/rimraf'
+1 -2
View File
@@ -6,9 +6,8 @@ import { assertProject } from '@pnpm/assert-project'
import { PnpmError } from '@pnpm/error'
import { importCommand } from '@pnpm/installing.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { temporaryDirectory } from 'tempy'
const f = fixtures(import.meta.dirname)
+1 -1
View File
@@ -4,8 +4,8 @@ import path from 'node:path'
import { expect, test } from '@jest/globals'
import { assertProject } from '@pnpm/assert-project'
import { importCommand } from '@pnpm/installing.commands'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { filterProjectsBySelectorObjectsFromDir } from '@pnpm/workspace.projects-filter'
import { temporaryDirectory } from 'tempy'
+1 -1
View File
@@ -3,7 +3,7 @@ import path from 'node:path'
import { expect, test } from '@jest/globals'
import { add, install } from '@pnpm/installing.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { temporaryDirectory } from 'tempy'
const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
+1 -1
View File
@@ -4,9 +4,9 @@ import path from 'node:path'
import { expect, test } from '@jest/globals'
import { add, install, prune } from '@pnpm/installing.commands'
import { prepare } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { createTestIpcServer } from '@pnpm/test-ipc-server'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { symlinkDirSync } from 'symlink-dir'
const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
@@ -3,8 +3,7 @@ import path from 'node:path'
import { expect, jest, test } from '@jest/globals'
import type { LockfileObject } from '@pnpm/lockfile.types'
import { prepare, preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { filterProjectsBySelectorObjectsFromDir } from '@pnpm/workspace.projects-filter'
import chalk from 'chalk'
import { readYamlFileSync } from 'read-yaml-file'
@@ -2,7 +2,7 @@ import path from 'node:path'
import { jest, test } from '@jest/globals'
import { preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { filterProjectsBySelectorObjectsFromDir } from '@pnpm/workspace.projects-filter'
jest.unstable_mockModule('@inquirer/prompts', () => {
-1
View File
@@ -136,7 +136,6 @@
"@pnpm/network.git-utils": "workspace:*",
"@pnpm/pkg-manifest.reader": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/resolving.registry.types": "workspace:*",
"@pnpm/store.cafs": "workspace:*",
"@pnpm/store.path": "workspace:*",
@@ -2,8 +2,7 @@ import { expect, test } from '@jest/globals'
import { LOCKFILE_VERSION } from '@pnpm/constants'
import { addDependenciesToPackage } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, getIntegrity } from '@pnpm/testing.registry-mock'
import { testDefaults } from '../utils/index.js'
@@ -3,8 +3,7 @@ import path from 'node:path'
import { test } from '@jest/globals'
import { addDependenciesToPackage, install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { addUser } from '@pnpm/testing.registry-mock'
import { addUser, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { RegistryConfig } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
@@ -5,8 +5,7 @@ import { assertProject } from '@pnpm/assert-project'
import { createPeerDepGraphHash } from '@pnpm/deps.path'
import { addDependenciesToPackage, install, mutateModules, mutateModulesInSingleProject, type PackageManifest } from '@pnpm/installing.deps-installer'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { ProjectRootDir } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
@@ -2,7 +2,7 @@ import { expect, test } from '@jest/globals'
import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
import { addDependenciesToPackage, install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import { getIntegrity } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { writeYamlFileSync } from 'write-yaml-file'
@@ -2,7 +2,7 @@ import { expect, test } from '@jest/globals'
import type { CustomResolver } from '@pnpm/hooks.types'
import { addDependenciesToPackage } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { testDefaults } from '../utils/index.js'
@@ -2,8 +2,8 @@ import { afterEach, beforeEach, expect, test } from '@jest/globals'
import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
import { addDependenciesToPackage, install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import { getMockAgent, setupMockAgent, teardownMockAgent } from '@pnpm/testing.mock-agent'
import { getIntegrity } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { writeYamlFileSync } from 'write-yaml-file'
@@ -4,9 +4,9 @@ import { expect, test } from '@jest/globals'
import type { PnpmError } from '@pnpm/error'
import { addDependenciesToPackage, mutateModulesInSingleProject } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { getMockAgent, setupMockAgent, teardownMockAgent } from '@pnpm/testing.mock-agent'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { ProjectRootDir } from '@pnpm/types'
import { loadJsonFileSync } from 'load-json-file'
@@ -1,7 +1,7 @@
import { expect, test } from '@jest/globals'
import { addDependenciesToPackage } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { testDefaults } from '../utils/index.js'
@@ -5,10 +5,9 @@ import { afterAll, expect, test } from '@jest/globals'
import { assertProject } from '@pnpm/assert-project'
import { install, type MutatedProject, mutateModules, type ProjectOptions } from '@pnpm/installing.deps-installer'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import type { PackageFilesIndex } from '@pnpm/store.cafs'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, getIntegrity } from '@pnpm/testing.registry-mock'
import type { ProjectRootDir } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
@@ -9,8 +9,7 @@ import {
install,
} from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { testDefaults } from '../utils/index.js'
@@ -11,9 +11,8 @@ import {
UnexpectedVirtualStoreDirError,
} from '@pnpm/installing.deps-installer'
import { prepare, prepareEmpty, preparePackages } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { ProjectManifest, ProjectRootDir } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
import { isCI } from 'ci-info'
@@ -5,8 +5,8 @@ import { expect, test } from '@jest/globals'
import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants'
import { addDependenciesToPackage, install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import type { VariationsResolution } from '@pnpm/resolving.resolver-base'
import { getIntegrity } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { writeYamlFileSync } from 'write-yaml-file'
@@ -6,10 +6,10 @@ import { ENGINE_NAME } from '@pnpm/constants'
import { createHexHashFromFile } from '@pnpm/crypto.hash'
import { install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import type { PackageFilesIndex } from '@pnpm/store.cafs'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { fixtures } from '@pnpm/test-fixtures'
import { getIntegrity } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { testDefaults } from '../utils/index.js'
@@ -16,9 +16,8 @@ import {
} from '@pnpm/installing.deps-installer'
import type { LockfileFile } from '@pnpm/lockfile.fs'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { ProjectRootDir } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
import deepRequireCwd from 'deep-require-cwd'
@@ -6,9 +6,9 @@ import { ENGINE_NAME } from '@pnpm/constants'
import { hashObject } from '@pnpm/crypto.object-hasher'
import { addDependenciesToPackage, install } from '@pnpm/installing.deps-installer'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getFilePathByModeInCafs, type PackageFilesIndex } from '@pnpm/store.cafs'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { rimrafSync } from '@zkochan/rimraf'
import { testDefaults } from '../utils/index.js'
+1 -2
View File
@@ -16,10 +16,9 @@ import type { LockfileObject, TarballResolution } from '@pnpm/lockfile.fs'
import type { LockfileFile } from '@pnpm/lockfile.types'
import { readPackageJsonFromDir } from '@pnpm/pkg-manifest.reader'
import { prepareEmpty, preparePackages, tempDir } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { getMockAgent, setupMockAgent, teardownMockAgent } from '@pnpm/testing.mock-agent'
import { addDistTag } from '@pnpm/testing.registry-mock'
import { addDistTag, getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { DepPath, ProjectManifest, ProjectRootDir } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
import { loadJsonFileSync } from 'load-json-file'
+1 -1
View File
@@ -10,8 +10,8 @@ import {
} from '@pnpm/installing.deps-installer'
import type { LockfileObject } from '@pnpm/lockfile.fs'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import type { PackageManifest, ProjectRootDir } from '@pnpm/types'
import existsSymlink from 'exists-link'
import { readYamlFileSync } from 'read-yaml-file'
@@ -1,8 +1,8 @@
import type { CustomResolver } from '@pnpm/hooks.types'
import type { InstallOptions } from '@pnpm/installing.deps-installer'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import type { ResolutionVerifier } from '@pnpm/resolving.resolver-base'
import type { StoreController } from '@pnpm/store.controller-types'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { createTempStore } from '@pnpm/testing.temp-store'
import type { Registries } from '@pnpm/types'
+1 -1
View File
@@ -85,12 +85,12 @@
"@pnpm/installing.read-projects-context": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store.cafs": "workspace:*",
"@pnpm/store.index": "workspace:*",
"@pnpm/store.path": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/test-ipc-server": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/testing.temp-store": "workspace:*",
"@types/fs-extra": "catalog:",
"@types/ramda": "catalog:",
+1 -1
View File
@@ -10,11 +10,11 @@ import { headlessInstall } from '@pnpm/installing.deps-restorer'
import { readModulesManifest } from '@pnpm/installing.modules-yaml'
import { readWantedLockfile } from '@pnpm/lockfile.fs'
import { tempDir } from '@pnpm/prepare'
import { getIntegrity } from '@pnpm/registry-mock'
import type { PackageFilesIndex } from '@pnpm/store.cafs'
import { StoreIndex, storeIndexKey } from '@pnpm/store.index'
import { fixtures } from '@pnpm/test-fixtures'
import { createTestIpcServer } from '@pnpm/test-ipc-server'
import { getIntegrity } from '@pnpm/testing.registry-mock'
import type { DepPath } from '@pnpm/types'
import { rimrafSync } from '@zkochan/rimraf'
import { loadJsonFileSync } from 'load-json-file'
@@ -3,8 +3,8 @@ import path from 'node:path'
import type { HeadlessOptions } from '@pnpm/installing.deps-restorer'
import { readProjectsContext } from '@pnpm/installing.read-projects-context'
import { safeReadPackageJsonFromDir } from '@pnpm/pkg-manifest.reader'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getStorePath } from '@pnpm/store.path'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { createTempStore } from '@pnpm/testing.temp-store'
import { temporaryDirectory } from 'tempy'
+3
View File
@@ -96,6 +96,9 @@
{
"path": "../../store/path"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../../testing/temp-store"
},
+1 -1
View File
@@ -67,7 +67,7 @@
"@jest/globals": "catalog:",
"@pnpm/installing.env-installer": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/testing.temp-store": "workspace:*",
"@types/semver": "catalog:",
"load-json-file": "catalog:",
@@ -6,7 +6,7 @@ import { expect, test } from '@jest/globals'
import { installConfigDeps } from '@pnpm/installing.env-installer'
import { createEnvLockfile, type EnvLockfile, readEnvLockfile } from '@pnpm/lockfile.fs'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { createTempStore } from '@pnpm/testing.temp-store'
import { rimraf } from '@zkochan/rimraf'
import { loadJsonFileSync } from 'load-json-file'
@@ -5,7 +5,7 @@ import { resolveAndInstallConfigDeps } from '@pnpm/installing.env-installer'
import { createEnvLockfile, readEnvLockfile, writeEnvLockfile } from '@pnpm/lockfile.fs'
import { type LogBase, streamParser } from '@pnpm/logger'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { createTempStore } from '@pnpm/testing.temp-store'
import { loadJsonFileSync } from 'load-json-file'
@@ -4,7 +4,7 @@ import { expect, test } from '@jest/globals'
import { resolveConfigDeps } from '@pnpm/installing.env-installer'
import { readEnvLockfile, writeEnvLockfile } from '@pnpm/lockfile.fs'
import { prepareEmpty } from '@pnpm/prepare'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { createTempStore } from '@pnpm/testing.temp-store'
import { readYamlFileSync } from 'read-yaml-file'
+3
View File
@@ -72,6 +72,9 @@
{
"path": "../../store/controller-types"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../../testing/temp-store"
},
+1 -1
View File
@@ -66,11 +66,11 @@
"@pnpm/installing.client": "workspace:*",
"@pnpm/installing.package-requester": "workspace:*",
"@pnpm/logger": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/store.cafs-types": "workspace:*",
"@pnpm/store.create-cafs-store": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/testing.mock-agent": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
"@types/normalize-path": "catalog:",
"@types/ramda": "catalog:",
"@types/semver": "catalog:",
+1 -1
View File
@@ -7,13 +7,13 @@ import { depPathToFilename } from '@pnpm/deps.path'
import { createClient } from '@pnpm/installing.client'
import { createPackageRequester, type PackageResponse } from '@pnpm/installing.package-requester'
import { streamParser } from '@pnpm/logger'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import type { PackageFilesIndex } from '@pnpm/store.cafs'
import type { PkgRequestFetchResult, PkgResolutionId, RequestPackageOptions } from '@pnpm/store.controller-types'
import { createCafsStore } from '@pnpm/store.create-cafs-store'
import { StoreIndex } from '@pnpm/store.index'
import { fixtures } from '@pnpm/test-fixtures'
import { setupMockAgent, teardownMockAgent } from '@pnpm/testing.mock-agent'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { restartWorkerPool } from '@pnpm/worker'
import delay from 'delay'
import normalize from 'normalize-path'
@@ -63,6 +63,9 @@
{
"path": "../../testing/mock-agent"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../../worker"
},
+6 -4
View File
@@ -186,13 +186,15 @@ Warnings are errors (`--deny warnings` in lint). Do not silence them with
## Tests
- Tests live alongside the code they exercise (standard Cargo layout) plus
integration tests under each crate's `tests/`. Shared test fixtures live
under `crates/testing-utils/src/fixtures/`.
integration tests under each crate's `tests/`. Shared pacquet fixtures live
under `crates/testing-utils/src/fixtures/`; registry package fixtures live
under `../registry/.fixtures/packages/`.
- Snapshot tests use `insta`. When an intentional change alters a snapshot,
review the diff carefully, then accept with `cargo insta review`. Never
accept snapshot changes blindly.
- Some tests require the mocked registry. Start it with
`just registry-mock launch` if a test needs it.
- Tests that need the mocked registry start `pnpm-registry` through
`pacquet-testing-utils`; `cargo test` / `cargo nextest run` should not
require a separate `just registry-mock launch` step.
- When porting behavior from pnpm, port the relevant pnpm tests too (as Rust
tests) whenever they translate. Matching test coverage is the easiest way
to prove behavioral parity.
+1 -2
View File
@@ -102,7 +102,7 @@ This runs `typos`, `cargo fmt`, `just check` (which is `cargo check --locked --w
> Run `just ready` before every commit. This rule applies to all changes, including documentation edits, comment changes, and config updates. Any change can break formatting, linting, building, or tests across the supported platforms.
> [!NOTE]
> Some integration tests require the local registry mock. Start it with `just registry-mock launch` before running `just test` if a test needs it.
> Integration tests that need the local registry mock start `pnpm-registry` automatically. After dependencies are installed, `cargo test`, `cargo nextest run`, and `just test` should not require a separate registry process.
## Debugging
@@ -116,7 +116,6 @@ TRACE=pacquet_tarball just cli add fastify
```sh
just install # install necessary dependencies
just registry-mock launch # start a mocked registry server (optional)
just test # run tests
```
+3 -3
View File
@@ -136,12 +136,12 @@ fn should_install_index_files() {
drop((root, mock_instance)); // cleanup
}
// Ignored on CI: the test drives the mocked verdaccio with hundreds of
// Ignored on CI: the test drives the registry fixture with hundreds of
// concurrent tarball fetches and reliably reports ConnectionAborted (Windows) /
// ConnectionReset (macOS) / ConnectionClosed (Ubuntu) on hosted runners. Run
// manually with `just registry-mock launch` + `cargo test --test install -- --ignored
// manually with `cargo test --test install -- --ignored
// frozen_lockfile_should_be_able_to_handle_big_lockfile`.
#[ignore = "flaky on CI: mocked verdaccio drops connections under concurrent load"]
#[ignore = "flaky on CI: registry fixture drops connections under concurrent load"]
#[test]
fn frozen_lockfile_should_be_able_to_handle_big_lockfile() {
let CommandTempCwd { pacquet, root, workspace, npmrc_info, .. } =
@@ -1,6 +1,5 @@
---
source: pacquet/crates/cli/tests/install.rs
assertion_line: 49
expression: "(workspace_folders, store_files)"
---
(
@@ -29,10 +28,10 @@ expression: "(workspace_folders, store_files)"
],
[
"v11/files/02/f9d952341eade675d0a8f5da14d4277fded62f937242292c2cf5f1bb0eda101b5f803098d64e2a138f4bfe4cdf326cfaf8f6b4015476ab86d25df03ddec731-exec",
"v11/files/2f/b86ecd88e34f18360bf865231219f7898cf713f63ad6d099f72b821f47cded6b92ece8d468775219a2950c50451d3f3e2f3920d15b4a3c372098f2daff864b",
"v11/files/65/d9491d753c9cff7b6d93461c83b8542a36db429a4cba4c712f841ae657f0d82b36d94081816d5a92ce761146c64b036ea1d89d53890c86b115d457bb98fa6b",
"v11/files/68/b837b4fd7982b081521e51b14a167ccdb272b3c499202449d07d48d78a2fa7bb8652d3a894bb06ac6e3995e5126ee3470f73b5775584940751fce8be468405",
"v11/files/76/7494fa050e61986b11b9d8af9a97faec0065fb71983265000e596f1b9cd8c35bda0ba18b643064ffc3e08da7da1afc42f6548f7939a91526f5780abbe1af10",
"v11/files/93/e31fcd9144a604f87d04fa8fb4a058202c579df17fd2b21301e17ac0ae4f3e2bae90ced7ae71b71218bd4a789e355ef7b8bd8899cdb785250071b229503b2e",
"v11/files/bf/0c878f2a4f2ec6f231bb2d414547efb15eb22a673815cba36acfd89633cd4c8affcbdc9378e90ad4d8fc654de921d1f67444be94e6a2f81bda9330be60be93-exec",
"v11/files/fe/06f6dff7c043b7ea30547ff55a8fd06fecc30fe143e3acf09cdd30def35d660f8cafa74ff28287748f661bbd767987eed52b440c77942eb0fb9aa6f44cfb37",
"v11/index.db",
],
)
@@ -1,13 +1,12 @@
---
source: crates/cli/tests/install.rs
assertion_line: 108
source: pacquet/crates/cli/tests/install.rs
expression: store_files
---
[
"v11/files/02/f9d952341eade675d0a8f5da14d4277fded62f937242292c2cf5f1bb0eda101b5f803098d64e2a138f4bfe4cdf326cfaf8f6b4015476ab86d25df03ddec731-exec",
"v11/files/2f/b86ecd88e34f18360bf865231219f7898cf713f63ad6d099f72b821f47cded6b92ece8d468775219a2950c50451d3f3e2f3920d15b4a3c372098f2daff864b",
"v11/files/65/d9491d753c9cff7b6d93461c83b8542a36db429a4cba4c712f841ae657f0d82b36d94081816d5a92ce761146c64b036ea1d89d53890c86b115d457bb98fa6b",
"v11/files/68/b837b4fd7982b081521e51b14a167ccdb272b3c499202449d07d48d78a2fa7bb8652d3a894bb06ac6e3995e5126ee3470f73b5775584940751fce8be468405",
"v11/files/76/7494fa050e61986b11b9d8af9a97faec0065fb71983265000e596f1b9cd8c35bda0ba18b643064ffc3e08da7da1afc42f6548f7939a91526f5780abbe1af10",
"v11/files/93/e31fcd9144a604f87d04fa8fb4a058202c579df17fd2b21301e17ac0ae4f3e2bae90ced7ae71b71218bd4a789e355ef7b8bd8899cdb785250071b229503b2e",
"v11/files/bf/0c878f2a4f2ec6f231bb2d414547efb15eb22a673815cba36acfd89633cd4c8affcbdc9378e90ad4d8fc654de921d1f67444be94e6a2f81bda9330be60be93-exec",
"v11/files/fe/06f6dff7c043b7ea30547ff55a8fd06fecc30fe143e3acf09cdd30def35d660f8cafa74ff28287748f661bbd767987eed52b440c77942eb0fb9aa6f44cfb37",
"v11/index.db",
]
@@ -1,31 +1,30 @@
---
source: crates/cli/tests/install.rs
assertion_line: 133
source: pacquet/crates/cli/tests/install.rs
expression: index_file_contents
---
"sha512-G3aEYkPR7vdClnAaLekaPPXJdy1fDE7I0j8HagQDeJ9x3hX4iACybYTL7yZr6i69UsmK/Ho7xyxQII0OARxawA==\t@pnpm.e2e/hello-world-js-bin-parent@1.0.0":
"sha512-CapZoP8cyT6kYKGzA1VQH0+l+MHUzfZzPpsgmQxkCkRLAyPmLdkFi5J/qazltGsUY1f3HlgrI0fJckcZQi8Idg==\t@pnpm.e2e/hello-world-js-bin@1.0.0":
LICENSE:
digest: 65d9491d753c9cff7b6d93461c83b8542a36db429a4cba4c712f841ae657f0d82b36d94081816d5a92ce761146c64b036ea1d89d53890c86b115d457bb98fa6b
digest: 767494fa050e61986b11b9d8af9a97faec0065fb71983265000e596f1b9cd8c35bda0ba18b643064ffc3e08da7da1afc42f6548f7939a91526f5780abbe1af10
mode: 420
size: 1066
index.js:
digest: 02f9d952341eade675d0a8f5da14d4277fded62f937242292c2cf5f1bb0eda101b5f803098d64e2a138f4bfe4cdf326cfaf8f6b4015476ab86d25df03ddec731
mode: 493
size: 79
package.json:
digest: fe06f6dff7c043b7ea30547ff55a8fd06fecc30fe143e3acf09cdd30def35d660f8cafa74ff28287748f661bbd767987eed52b440c77942eb0fb9aa6f44cfb37
mode: 420
size: 536
"sha512-bFWeEhV2pspARSwVwLnMfQStl22sXBuexcX+OvSlMw5hKw3tpyqeDCEA04qhdo1XCX1Hag0pBuI6H9Ri0ctzOw==\t@pnpm.e2e/hello-world-js-bin@1.0.0":
LICENSE:
digest: 65d9491d753c9cff7b6d93461c83b8542a36db429a4cba4c712f841ae657f0d82b36d94081816d5a92ce761146c64b036ea1d89d53890c86b115d457bb98fa6b
mode: 420
size: 1066
size: 1170
index.js:
digest: bf0c878f2a4f2ec6f231bb2d414547efb15eb22a673815cba36acfd89633cd4c8affcbdc9378e90ad4d8fc654de921d1f67444be94e6a2f81bda9330be60be93
mode: 493
size: 48
package.json:
digest: 2fb86ecd88e34f18360bf865231219f7898cf713f63ad6d099f72b821f47cded6b92ece8d468775219a2950c50451d3f3e2f3920d15b4a3c372098f2daff864b
digest: 68b837b4fd7982b081521e51b14a167ccdb272b3c499202449d07d48d78a2fa7bb8652d3a894bb06ac6e3995e5126ee3470f73b5775584940751fce8be468405
mode: 420
size: 410
size: 379
"sha512-P9VEb+AGUvzD40fpbbaO+ycsz+HMFTHfb/M4nZNChq77Q/umVX2brpidjLd00s0GpXm/quE1mr0h8Aiacz85xw==\t@pnpm.e2e/hello-world-js-bin-parent@1.0.0":
LICENSE:
digest: 767494fa050e61986b11b9d8af9a97faec0065fb71983265000e596f1b9cd8c35bda0ba18b643064ffc3e08da7da1afc42f6548f7939a91526f5780abbe1af10
mode: 420
size: 1170
index.js:
digest: 02f9d952341eade675d0a8f5da14d4277fded62f937242292c2cf5f1bb0eda101b5f803098d64e2a138f4bfe4cdf326cfaf8f6b4015476ab86d25df03ddec731
mode: 493
size: 79
package.json:
digest: 93e31fcd9144a604f87d04fa8fb4a058202c579df17fd2b21301e17ac0ae4f3e2bae90ced7ae71b71218bd4a789e355ef7b8bd8899cdb785250071b229503b2e
mode: 420
size: 537
@@ -69,7 +69,6 @@ tracing = { workspace = true }
miette = { workspace = true }
[dev-dependencies]
pacquet-registry-mock = { workspace = true }
pacquet-testing-utils = { workspace = true }
node-semver = { workspace = true }
@@ -6,7 +6,6 @@ use pacquet_modules_yaml::{
read_modules_manifest, write_modules_manifest,
};
use pacquet_package_manifest::{DependencyGroup, PackageManifest};
use pacquet_registry_mock::AutoMockInstance;
use pacquet_reporter::{
BrokenModulesLog, ContextLog, IgnoredScriptsLog, LogEvent, PackageManifestLog,
PackageManifestMessage, ProgressLog, ProgressMessage, Reporter, SilentReporter, Stage,
@@ -14,6 +13,7 @@ use pacquet_reporter::{
};
use pacquet_store_dir::STORE_VERSION;
use pacquet_testing_utils::fs::{get_all_folders, is_symlink_or_junction};
use pacquet_testing_utils::registry::TestRegistry;
use pacquet_workspace_state::{
self as workspace_state, NodeLinker as WorkspaceStateNodeLinker, load_workspace_state,
};
@@ -24,7 +24,7 @@ use text_block_macros::text_block;
#[tokio::test]
async fn should_install_dependencies() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -282,7 +282,7 @@ async fn frozen_lockfile_flag_overrides_config_lockfile_false() {
/// <https://github.com/pnpm/pnpm/blob/1819226b51/resolving/npm-resolver/src/parseBareSpecifier.ts>
#[tokio::test]
async fn npm_alias_dependency_installs_under_alias_key() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -366,7 +366,7 @@ async fn npm_alias_dependency_installs_under_alias_key() {
/// but omit the `@1.0.0` suffix to trigger the default-to-`latest` path.
#[tokio::test]
async fn unversioned_npm_alias_defaults_to_latest() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -985,7 +985,7 @@ mod build_workspace_state_tests {
/// resolves.
#[tokio::test]
async fn install_optional_failing_postinstall_dep_via_registry_mock_succeeds() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -1060,7 +1060,7 @@ async fn install_optional_failing_postinstall_dep_via_registry_mock_succeeds() {
/// [`peerDependencies.ts:1181-1255`](https://github.com/pnpm/pnpm/blob/1fb8a2d5d8/installing/deps-installer/test/install/peerDependencies.ts#L1181-L1255).
#[tokio::test]
async fn auto_install_peers_does_not_cascade_optional_peers() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -1158,7 +1158,7 @@ async fn auto_install_peers_does_not_cascade_optional_peers() {
/// [`installing/deps-installer/test/install/peerDependencies.ts`](https://github.com/pnpm/pnpm/blob/1fb8a2d5d8/installing/deps-installer/test/install/peerDependencies.ts#L1257-L1323).
#[tokio::test]
async fn auto_install_peers_skips_meta_only_optional_peers() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -3812,7 +3812,7 @@ async fn install_rejects_invalid_minimum_release_age_exclude_pattern() {
/// project's `node_modules` symlink exist.
#[tokio::test]
async fn frozen_lockfile_gate_rejects_under_huge_minimum_release_age() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -3925,7 +3925,7 @@ async fn frozen_lockfile_gate_rejects_under_huge_minimum_release_age() {
/// under `.`, and matching `packages:` / `snapshots:` rows.
#[tokio::test]
async fn fresh_install_writes_pnpm_lock_yaml_with_expected_shape() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4010,7 +4010,7 @@ async fn fresh_install_writes_pnpm_lock_yaml_with_expected_shape() {
/// lands in the lockfile's `devDependencies` section.
#[tokio::test]
async fn fresh_install_splits_dev_and_prod_dependency_sections() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4083,7 +4083,7 @@ async fn fresh_install_splits_dev_and_prod_dependency_sections() {
/// (`1.0.0`).
#[tokio::test]
async fn fresh_install_records_user_written_specifier() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4151,7 +4151,7 @@ async fn fresh_install_records_user_written_specifier() {
/// don't catch because they assert on the in-memory shape).
#[tokio::test]
async fn fresh_install_lockfile_round_trips_through_load_save_load() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4217,7 +4217,7 @@ async fn fresh_install_lockfile_round_trips_through_load_save_load() {
/// no `pnpm-lock.yaml` on disk, but `node_modules/` materialized.
#[tokio::test]
async fn fresh_install_with_lockfile_disabled_does_not_write_a_lockfile() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4288,7 +4288,7 @@ async fn fresh_install_with_lockfile_disabled_does_not_write_a_lockfile() {
/// --frozen-lockfile` can read it back without a parse error.
#[tokio::test]
async fn fresh_install_also_writes_current_lockfile_under_virtual_store() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4373,7 +4373,7 @@ async fn fresh_install_also_writes_current_lockfile_under_virtual_store() {
/// matching upstream pnpm's all-or-nothing `useLockfile` behavior.
#[tokio::test]
async fn fresh_install_with_lockfile_disabled_skips_current_lockfile_too() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -4437,7 +4437,7 @@ async fn fresh_install_with_lockfile_disabled_skips_current_lockfile_too() {
/// sibling lands `optional: false` so the test pins both sides.
#[tokio::test]
async fn fresh_install_marks_optional_snapshots_in_pnpm_lock_yaml() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -5624,7 +5624,7 @@ async fn optimistic_repeat_install_does_not_short_circuit_when_lockfile_missing(
/// (which covers the negative direction).
#[tokio::test]
async fn optimistic_repeat_install_round_trips_on_single_project_install() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -5771,7 +5771,7 @@ async fn optimistic_repeat_install_round_trips_on_single_project_install() {
/// [`crate::FreshnessCheckError::Stale`]).
#[tokio::test]
async fn fresh_install_applies_package_extensions_to_dependency_manifest() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let dir = tempdir().unwrap();
let store_dir = dir.path().join("pacquet-store");
@@ -2,7 +2,6 @@ use super::{InstallPackageFromRegistry, InstallPackageFromRegistryError};
use pacquet_config::Config;
use pacquet_lockfile::{LockfileResolution, TarballResolution};
use pacquet_network::ThrottledClient;
use pacquet_registry_mock::AutoMockInstance;
use pacquet_reporter::{LogEvent, ProgressMessage, Reporter, SilentReporter};
use pacquet_resolving_npm_resolver::{
InMemoryPackageMetaCache, NpmResolver, shared_packument_fetch_locker,
@@ -10,6 +9,7 @@ use pacquet_resolving_npm_resolver::{
};
use pacquet_resolving_resolver_base::{ResolveOptions, ResolveResult, Resolver, WantedDependency};
use pacquet_store_dir::{SharedVerifiedFilesCache, StoreDir};
use pacquet_testing_utils::registry::TestRegistry;
use pipe_trait::Pipe;
use pretty_assertions::assert_eq;
use std::{
@@ -144,7 +144,7 @@ async fn resolve_via_mock(
#[tokio::test]
pub async fn should_install_package_from_pre_resolved_result() {
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let store_dir = tempdir().unwrap();
let modules_dir = tempdir().unwrap();
let virtual_store_dir = tempdir().unwrap();
@@ -227,7 +227,7 @@ async fn second_visit_skips_progress_emits_but_still_links() {
}
}
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let store_dir = tempdir().unwrap();
let modules_dir = tempdir().unwrap();
let second_parent_dir = tempdir().unwrap();
@@ -343,7 +343,7 @@ async fn install_emits_progress_sequence() {
}
}
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let store_dir = tempdir().unwrap();
let modules_dir = tempdir().unwrap();
Binary file not shown.
+8 -7
View File
@@ -11,13 +11,14 @@ license.workspace = true
repository.workspace = true
[dependencies]
pacquet-registry-mock = { workspace = true }
assert_cmd = { workspace = true }
command-extra = { workspace = true }
tempfile = { workspace = true }
walkdir = { workspace = true }
text-block-macros = { workspace = true }
assert_cmd = { workspace = true }
command-extra = { workspace = true }
pnpm-registry = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true }
walkdir = { workspace = true }
text-block-macros = { workspace = true }
pnpm-registry-fixtures = { workspace = true }
[target.'cfg(windows)'.dependencies]
junction = { workspace = true }
+4 -4
View File
@@ -1,6 +1,6 @@
use crate::registry::TestRegistry;
use assert_cmd::prelude::*;
use command_extra::CommandExtra;
use pacquet_registry_mock::AutoMockInstance;
use std::{fs, path::PathBuf, process::Command};
use tempfile::{TempDir, tempdir};
use text_block_macros::text_block_fnl;
@@ -44,8 +44,8 @@ pub struct AddMockedRegistry {
pub store_dir: PathBuf,
/// Absolute path to the cache directory as defined by the `.npmrc` file.
pub cache_dir: PathBuf,
/// Anchor to a mocked registry instance. The server will be stop when [dropped](Drop).
pub mock_instance: AutoMockInstance,
/// Handle to the process-scoped mocked registry used by this test.
pub mock_instance: TestRegistry,
}
impl CommandTempCwd<()> {
@@ -61,7 +61,7 @@ impl CommandTempCwd<()> {
"store-dir=../pacquet-store"
"cache-dir=../pacquet-cache"
};
let mock_instance = AutoMockInstance::load_or_init();
let mock_instance = TestRegistry::start();
let mocked_registry = mock_instance.url();
let npmrc_text = format!("registry={mocked_registry}\n{npmrc_text}");
fs::write(&npmrc_path, npmrc_text).expect("write to .npmrc");
+1
View File
@@ -3,3 +3,4 @@ pub mod env_guard;
pub mod fixtures;
pub mod fs;
pub mod known_failure;
pub mod registry;
@@ -0,0 +1,70 @@
use pnpm_registry::Config;
use std::{
net::{Ipv4Addr, TcpListener},
sync::OnceLock,
thread,
};
#[derive(Debug)]
#[must_use]
pub struct TestRegistry {
instance: &'static TestRegistryInstance,
}
impl TestRegistry {
pub fn start() -> Self {
Self { instance: TestRegistryInstance::get() }
}
pub fn url(&self) -> String {
self.instance.url.clone()
}
}
#[derive(Debug)]
struct TestRegistryInstance {
url: String,
}
impl TestRegistryInstance {
fn get() -> &'static Self {
static INSTANCE: OnceLock<TestRegistryInstance> = OnceLock::new();
INSTANCE.get_or_init(Self::start)
}
fn start() -> Self {
let listener = TcpListener::bind((Ipv4Addr::LOCALHOST, 0))
.expect("bind test registry to an unused localhost port");
listener.set_nonblocking(true).expect("set test registry listener to nonblocking");
let listen = listener.local_addr().expect("read test registry listener address");
let url = format!("http://{listen}/");
let storage = pnpm_registry_fixtures::ensure_storage();
// Proxy mode: `@pnpm.e2e` fixtures are served from local storage, while
// real npm packages (`is-positive`, `is-negative`, etc.) fall through to
// the npm uplink — matching how registry-mock served pacquet's tests.
let mut config = Config::proxy(listen, storage.to_path_buf());
config.public_url = url.trim_end_matches('/').to_string();
// A long TTL keeps the fixture packuments (whose `time` values are static)
// from being treated as stale and refetched from the uplink.
config.packument_ttl = std::time::Duration::from_secs(31_536_000);
thread::Builder::new()
.name("pacquet-test-registry".to_string())
.spawn(move || run_registry(config, listener))
.expect("spawn test registry thread");
Self { url }
}
}
fn run_registry(config: Config, listener: TcpListener) {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("create test registry runtime");
runtime.block_on(async move {
let listener = tokio::net::TcpListener::from_std(listener).expect("create tokio listener");
pnpm_registry::serve_listener(config, listener).await.expect("serve test registry");
});
}
+12 -11
View File
@@ -1,7 +1,7 @@
[package]
name = "pacquet-registry-mock"
version = "0.0.0"
description = "Drives pnpm-registry against @pnpm/registry-mock's shipped storage for pacquet tests"
description = "Drives pnpm-registry against the in-repo registry fixtures for pacquet benchmarks"
publish = false
authors.workspace = true
edition.workspace = true
@@ -21,16 +21,17 @@ path = "src/main.rs"
doc = false
[dependencies]
assert_cmd = { workspace = true }
clap = { workspace = true }
home = { workspace = true }
pipe-trait = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sysinfo = { workspace = true }
tokio = { workspace = true }
walkdir = { workspace = true }
assert_cmd = { workspace = true }
clap = { workspace = true }
home = { workspace = true }
pipe-trait = { workspace = true }
pnpm-registry-fixtures = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sysinfo = { workspace = true }
tokio = { workspace = true }
walkdir = { workspace = true }
[lints]
workspace = true
+1 -2
View File
@@ -3,8 +3,7 @@
"version": "1100.0.0",
"private": true,
"devDependencies": {
"@pnpm-private/pacquet-registry-mock-launcher": "workspace:*",
"@pnpm/registry-mock": "catalog:"
"@pnpm-private/pacquet-registry-mock-launcher": "workspace:*"
},
"keywords": [
"pnpm",
+8 -22
View File
@@ -31,26 +31,12 @@ pub fn workspace_root() -> &'static Path {
})
}
pub fn registry_mock() -> &'static Path {
static REGISTRY_MOCK: OnceLock<PathBuf> = OnceLock::new();
REGISTRY_MOCK
.get_or_init(|| workspace_root().join("pacquet").join("tasks").join("registry-mock"))
}
/// The verdaccio-shaped storage that `@pnpm/registry-mock`'s published
/// npm tarball ships under `registry/storage-cache/`. We don't serve
/// directly from here — see [`runtime_storage`] for why — but we
/// seed [`runtime_storage`] from it on every launch.
/// The verdaccio-shaped storage built from the in-repo package fixtures
/// (`registry/.fixtures/packages`) — the same storage pacquet's tests serve.
/// We don't serve directly from here — see [`runtime_storage`] for why — but
/// we seed [`runtime_storage`] from it on every launch.
pub fn registry_mock_storage() -> &'static Path {
static STORAGE: OnceLock<PathBuf> = OnceLock::new();
STORAGE.get_or_init(|| {
registry_mock()
.join("node_modules")
.join("@pnpm")
.join("registry-mock")
.join("registry")
.join("storage-cache")
})
pnpm_registry_fixtures::ensure_storage()
}
/// Stable cache path we hand to `pnpm-registry --storage` (instead
@@ -59,9 +45,9 @@ pub fn registry_mock_storage() -> &'static Path {
///
/// 1. `pnpm-registry` writes proxy-mode cache entries (the ~2.3k
/// unscoped npm packages the benchmark lockfile pulls) into
/// `--storage`. If we pointed at the registry-mock package's
/// install dir we'd pollute `node_modules` and lose every cached
/// entry when `pnpm install` recreates it.
/// `--storage`. If we pointed at the generated fixture storage
/// we'd mix proxy-cache entries into it and lose them whenever the
/// fixtures are rebuilt.
/// 2. CI caches this path across runs
/// (`.github/workflows/pacquet-integrated-benchmark.yml`). Without
/// that, cold-cache scenarios pay a full 2.3k-packument fetch
@@ -79,12 +79,11 @@ impl<'a> MockInstanceOptions<'a> {
let stderr = stderr.map_or_else(Stdio::null, |stderr| {
File::create(stderr).expect("create file for stderr").into()
});
// No `prepare` step needed — `@pnpm/registry-mock`'s npm
// tarball ships `registry/storage-cache/` already populated.
// pnpm-registry runs in proxy mode against npmjs.org so
// off-storage packages (`is-positive`, `json-append`, etc.)
// fall through to npm; see `pnpm_registry_command` for the
// rationale.
// Storage is built from the in-repo fixtures (see
// `registry_mock_storage`) and seeded into runtime storage by
// `pnpm_registry_command`. pnpm-registry runs in proxy mode
// against npmjs.org so off-fixture packages fall through to
// npm; see `pnpm_registry_command` for the rationale.
let process = pnpm_registry_command(port)
.stdin(Stdio::null())
.stdout(stdout)
@@ -45,14 +45,12 @@ fn pnpm_registry_binary() -> PathBuf {
}
/// Build a [`Command`] that spawns the `pnpm-registry` binary in
/// proxy mode against `@pnpm/registry-mock`'s prepared storage
/// directory, with `registry.npmjs.org` as the upstream.
/// proxy mode against the storage built from the in-repo fixtures,
/// with `registry.npmjs.org` as the upstream.
///
/// This mirrors verdaccio's `'**': proxy: npmjs` setup in
/// `@pnpm/registry-mock`'s `registry/config.yaml`: the storage
/// holds the scoped fixture packages (`@foo`, `@pnpm.e2e`, …) and
/// anything else (e.g. `is-positive`, `json-append`) is pulled
/// from npmjs.org on demand.
/// The storage holds the fixture packages (`@foo`, `@pnpm.e2e`, …)
/// and anything else (e.g. extra npm packages the benchmark lockfile
/// pulls) is fetched from npmjs.org on demand.
///
/// `--packument-ttl-secs 31536000` (one year) keeps the fixture
/// packuments authoritative across a test run: their on-disk
@@ -19,9 +19,9 @@ pub fn seed_runtime_storage() -> io::Result<usize> {
let src = registry_mock_storage();
let dest = runtime_storage();
if !src.exists() {
// The launcher needs registry-mock installed via pnpm — if
// it isn't, fall through with zero seeded and let
// pnpm-registry's own startup fail with a clear message.
// `registry_mock_storage` builds the fixture storage on first
// call, so this is unreachable in practice; guard anyway and
// let pnpm-registry's own startup surface any problem.
return Ok(0);
}
fs::create_dir_all(dest)?;
+1 -1
View File
@@ -75,9 +75,9 @@
"@pnpm/logger": "workspace:*",
"@pnpm/patching.commands": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "catalog:",
"@pnpm/test-fixtures": "workspace:*",
"@pnpm/testing.command-defaults": "workspace:*",
"@pnpm/testing.registry-mock": "workspace:*",
"@pnpm/workspace.projects-filter": "workspace:*",
"@types/is-windows": "catalog:",
"@types/normalize-path": "catalog:",
+1 -1
View File
@@ -6,8 +6,8 @@ import { beforeAll, beforeEach, describe, expect, it, jest, test } from '@jest/g
import { install } from '@pnpm/installing.commands'
import type { PatchCommandOptions, PatchRemoveCommandOptions } from '@pnpm/patching.commands'
import { prepare, preparePackages, tempDir } from '@pnpm/prepare'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { fixtures } from '@pnpm/test-fixtures'
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
import { readProjectManifest } from '@pnpm/workspace.project-manifest-reader'
import { filterProjectsBySelectorObjectsFromDir } from '@pnpm/workspace.projects-filter'
import { readWorkspaceManifest } from '@pnpm/workspace.workspace-manifest-reader'
+3
View File
@@ -72,6 +72,9 @@
{
"path": "../../testing/command-defaults"
},
{
"path": "../../testing/registry-mock"
},
{
"path": "../../workspace/project-manifest-reader"
},
Loaded 100 of 493 files, more files were not shown because too many files have changed in this diff. Show more