mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-30 01:16:56 -04:00
`TempDir::keep()` disables cleanup, and three of the four sites using it did not need to: the `'static` requirement was on the value being leaked (`StoreDir`, `Config`), never on the directory. A full run left ~45 directories in the system temp dir; it now leaves ~10. - `overrides::tests::manifest_from_value` wrote a `package.json` only to read it straight back, for a path its own doc calls a stub. It builds the manifest with `PackageManifest::from_value` instead, which touches no filesystem at all — one leak per call across ~25 callers, gone, and the helper drops to one line. - `env_installer::tests::harness` leaked the store directory alongside the `&'static StoreDir` pointing at it. The `TempDir` moves into `Harness`, which already exists to hold per-test handles. - `install_package_from_registry::tests::create_config` leaked a cache dir while every caller was separately creating one of its own and passing it to the resolver. It takes the caller's, so the config and the resolver now share a cache the way they do in practice. `cli/tests/pnpr_install.rs` keeps its `keep()`: the detached server thread outlives both the function and the test. Add `just sweep-test-temp` for the rest. A killed test process cannot run `Drop`, so a fail-fast or interrupted run always abandons whole fixture trees, including a per-test store for the mocked-registry tests. The sweep skips anything under an hour old so it cannot disturb a concurrent run. Redirecting `TMPDIR` at the whole suite does not work: tests assert on stderr containing paths under the temp dir, and a `TMPDIR` under `target/` makes the walk for `pnpm-workspace.yaml` find this repo's own. Related to pnpm/pnpm#12485.
127 lines
4.1 KiB
Makefile
127 lines
4.1 KiB
Makefile
#!/usr/bin/env -S just --justfile
|
|
|
|
_default:
|
|
just --list -u
|
|
|
|
alias r := ready
|
|
alias c := codecov
|
|
alias t := test
|
|
|
|
# Initialize the project by installing all the necessary tools.
|
|
# Make sure you have cargo-binstall installed.
|
|
# You can download the pre-compiled binary from <https://github.com/cargo-bins/cargo-binstall#installation>
|
|
# or install via `cargo install cargo-binstall`
|
|
init:
|
|
cargo binstall cargo-nextest cargo-watch cargo-insta typos-cli taplo-cli wasm-pack cargo-llvm-cov -y
|
|
|
|
# When ready, run the same CI commands
|
|
ready:
|
|
typos pnpm pnpr
|
|
cargo fmt
|
|
just check
|
|
just test
|
|
just lint
|
|
git status
|
|
|
|
# Update our local branch with the remote branch (this is for you to sync the submodules)
|
|
update:
|
|
git pull
|
|
git submodule update --init
|
|
|
|
# Install necessary dependencies.
|
|
# `pnpm/tasks/registry-mock` is a member of the root pnpm workspace,
|
|
# so the root install populates its node_modules.
|
|
install:
|
|
pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
# Run `cargo watch`
|
|
# --no-vcs-ignores: cargo-watch has a bug loading all .gitignores, including the ones listed in .gitignore
|
|
# use .ignore file getting the ignore list
|
|
watch command:
|
|
cargo watch --no-vcs-ignores -x '{{command}}'
|
|
|
|
# Format all files
|
|
fmt:
|
|
cargo fmt
|
|
taplo format
|
|
|
|
# Run cargo check
|
|
check:
|
|
cargo check --locked --workspace --all-targets
|
|
|
|
# Run all the tests.
|
|
test:
|
|
cargo nextest run
|
|
|
|
# A test process that is killed cannot run `TempDir`'s cleanup, so a
|
|
# fail-fast or interrupted run abandons whole fixture trees — each holding a
|
|
# per-test store for the mocked-registry tests, which is what actually adds
|
|
# up. Only `pacquet-test-*` is swept: that prefix comes from
|
|
# `CommandTempCwd`, so a match is known to be ours. `-mindepth 1` keeps the
|
|
# root itself out of the match, and the age floor leaves a concurrent run
|
|
# alone.
|
|
|
|
# Remove fixture trees that earlier test runs abandoned.
|
|
sweep-test-temp:
|
|
find "${TMPDIR:-/tmp}" -mindepth 1 -maxdepth 1 -name 'pacquet-test-*' -mmin +60 -exec rm -rf {} + 2>/dev/null || true
|
|
|
|
# Run pacquet package tests only.
|
|
test-pacquet:
|
|
cargo nextest run --workspace --exclude pnpr --exclude pnpr-fixtures
|
|
|
|
# Run pnpr package tests only.
|
|
test-pnpr:
|
|
cargo nextest run -p pnpr -p pnpr-fixtures
|
|
|
|
# List expected-failing test ports
|
|
[unix]
|
|
known-failures:
|
|
@cargo test --workspace known_failures -- --list 2>/dev/null | rg '^known_failures::'
|
|
|
|
[windows]
|
|
known-failures:
|
|
@cargo test --workspace known_failures -- --list 2>nul | rg '^known_failures::'
|
|
# Lint the whole project
|
|
lint:
|
|
cargo clippy --locked --workspace --all-targets -- --deny warnings
|
|
|
|
# Run perfectionist dylint rules. Requires `cargo-dylint` and `dylint-link`
|
|
# (install from source with `cargo install cargo-dylint dylint-link`; the
|
|
# prebuilt binstall binaries fail to build the driver locally). The lint
|
|
# library is pinned in `dylint.toml`.
|
|
dylint:
|
|
env RUSTFLAGS="-D warnings" cargo dylint --all -- --all-targets --workspace
|
|
|
|
# Get code coverage
|
|
codecov:
|
|
cargo codecov --html
|
|
|
|
# Run the benchmarks. See `tasks/benchmark`
|
|
micro-benchmark:
|
|
cargo run --bin=micro-benchmark --release
|
|
|
|
# Manage registry-mock. The launcher spawns `pnpr`; on
|
|
# Windows you can't overwrite a running .exe, so we pre-build all
|
|
# the test artifacts a subsequent `just test` will need with the
|
|
# exact same invocation. A `-p pnpr`-scoped pre-build is
|
|
# not enough — workspace-wide feature unification gives a
|
|
# different fingerprint and nextest would still try to re-link the
|
|
# running binary, failing with `os error 5` on Windows MSVC.
|
|
registry-mock +args:
|
|
cargo nextest run --no-run
|
|
cargo run --bin=pacquet-registry-mock -- {{args}}
|
|
|
|
# The benchmark may auto-spawn the registry mock (via
|
|
# `AutoMockInstance::load_or_init()`), so make sure `pnpr`
|
|
# is built before the executor runs — otherwise the spawn step
|
|
# aborts with "binary not found". Built with `--release` so the
|
|
# mock serves at optimized perf; a debug build would put the
|
|
# Rust mock at a multi-second handicap vs verdaccio, which V8
|
|
# always JITs, polluting the install-perf signal.
|
|
integrated-benchmark +args:
|
|
cargo build --release --bin=pnpr
|
|
cargo run --bin=integrated-benchmark -- {{args}}
|
|
|
|
cli +args:
|
|
cargo run --bin pnpm -- {{args}}
|