1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Shared `npx` gate for the tests that run a real `napi build`.
//!
//! Every such test invokes `npx --yes -p @napi-rs/cli@<version> ...`, and `npx` installs the
//! package into a shared cache directory keyed by the package spec on first use. Two tests that
//! reach that first use concurrently -- which `cargo test`'s default thread pool makes routine --
//! both install into the same directory, and the loser can observe the winner's half-written
//! `node_modules`: `Test (ubuntu-latest)` on 2026-09-18 failed both napi fixtures with
//! `ERR_MODULE_NOT_FOUND ... fast-string-truncated-width` under `~/.npm/_npx/`. The
//! [`OnceLock`] here performs that first install exactly once, before any test's own `npx` runs,
//! so the build commands only ever find an already-populated cache. ~keep
//!
//! [`OnceLock`]: std::sync::OnceLock
use cratetemplate_versions as tv;
/// Whether `npx` runs, not merely resolves, and `@napi-rs/cli` is installed in its cache.
///
/// A version-manager shim (e.g. nvm) spawns fine then exits non-zero, so a PATH-only check would
/// leave the callers' skip unreachable and fire their asserts everywhere Node is absent. ~keep
pub
/// Populate the `npx` cache for the exact package spec the build command emits, serialized
/// through the caller's [`std::sync::OnceLock`]. A failure here (no network on a cold cache, a
/// broken registry) is reported as "not runnable" so the callers skip, matching the convention
/// for tests that depend on an external toolchain.