supercov 4.24.8 → 4.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ // Yarn 1 runs `yarn supercov --exact-attribution -- npm test` as `supercov
2
+ // npm test`: it takes the options before `--` for its own and drops the
3
+ // `--`. The binary would measure without the option and never know. Yarn
4
+ // keeps what was typed in `npm_config_argv`, and it is used when it is this
5
+ // executable's command line: one Yarn started for `supercov`, of which what
6
+ // arrived is the words in order with some taken out. A variable inherited
7
+ // from an outer run names other words and is left alone. (A `--` lost on its
8
+ // own the binary recovers itself: it reads a first word that names a
9
+ // program as the test command.)
10
+ export function argumentsAsTyped(received, environment) {
11
+ if (!/^yarn\/1\./.test(environment.npm_config_user_agent ?? "")) return received;
12
+ let original;
13
+ try {
14
+ original = JSON.parse(environment.npm_config_argv ?? "").original;
15
+ } catch {
16
+ return received;
17
+ }
18
+ if (!Array.isArray(original) || !original.every((word) => typeof word === "string"))
19
+ return received;
20
+ const start = original[0] === "run" || original[0] === "exec" ? 1 : 0;
21
+ if (original[start] !== "supercov") return received;
22
+ const typed = original.slice(start + 1);
23
+ let matched = 0;
24
+ for (const word of typed) if (matched < received.length && word === received[matched]) matched += 1;
25
+ return matched === received.length && typed.length > received.length ? typed : received;
26
+ }
package/bin/supercov.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { spawn } from "node:child_process";
4
4
  import { dirname } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { argumentsAsTyped } from "./arguments.js";
6
7
  import { resolveNativeBinary } from "./native.js";
7
8
 
8
9
  let rustBinary;
@@ -14,7 +15,7 @@ try {
14
15
  }
15
16
  const child = spawn(
16
17
  rustBinary,
17
- process.argv.slice(2),
18
+ argumentsAsTyped(process.argv.slice(2), process.env),
18
19
  {
19
20
  stdio: "inherit",
20
21
  env: {
package/docs/cli.md CHANGED
@@ -122,6 +122,15 @@ npx supercov -- cargo nextest run
122
122
  Use the complete command you rely on before merging or deploying. A coverage run
123
123
  preserves the wrapped command's exit status, so it can remain a CI gate.
124
124
 
125
+ Some launchers drop the `--` before Supercov sees it: Bun when it runs the
126
+ script (`[run] bun = true`, `bun --bun run`, `bun run supercov`), Yarn 1's
127
+ `yarn supercov -- ...`, and PowerShell on its way into a package manager's
128
+ `.ps1` shim. A first word that is no Supercov command but a program on `PATH`,
129
+ or a path to one, is then still measured as the test command, and Yarn 1's
130
+ `--exact-attribution` is restored from what Yarn recorded. Under Yarn 1 in
131
+ PowerShell, a `--` of the test command's own is lost before Supercov runs:
132
+ put that command in a package script.
133
+
125
134
  A script that queries the run it just recorded can have Supercov write the
126
135
  run's id to a file. `latest` is the newest run, which is another one when two
127
136
  commands record runs side by side:
@@ -838,6 +847,13 @@ own:
838
847
  - run: npx supercov merge
839
848
  ```
840
849
 
850
+ Every machine must install the same dependencies. With a lockfile committed,
851
+ install it as it is in each job (`npm ci`, `pnpm install --frozen-lockfile`,
852
+ `yarn install --immutable`, `bun install --frozen-lockfile`). A repository
853
+ without one resolves its dependencies anew in each job, and `merge` leaves
854
+ every run out as `the dependencies have changed`: resolve the lockfile once in
855
+ a first job, pass it to the others as an artifact, and `npm ci` it there.
856
+
841
857
  `assertions assess` assesses a merged run across every suite merged into it,
842
858
  reusing the answers saved when its parts were assessed. `tests affected` of a
843
859
  merged run is answered from the runs it was merged from, which hold the record
@@ -81,6 +81,9 @@ npx supercov -- sh -c "npm run build && npm test"
81
81
  ```
82
82
 
83
83
  A `pretest` script, or a Playwright `webServer` that builds, does the same.
84
+ When this checkout holds build output the copy starts without, and the command
85
+ does not run the `build` script, Supercov says so before the suite runs, so a
86
+ long suite can be stopped and started again with the build in its command.
84
87
  When a run fails, it names the tests that failed. When none did and the
85
88
  project has a `build` script the command does not reach, it says the build
86
89
  output may be what is missing. `SUPERCOV_KEEP_WORKSPACE=1` leaves the instrumented copy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supercov",
3
- "version": "4.24.8",
3
+ "version": "4.26.0",
4
4
  "description": "Coverage, security and code quality for coding agents",
5
5
  "keywords": [
6
6
  "coverage",
@@ -117,20 +117,21 @@
117
117
  "docs:sync": "node scripts/sync-docs.mjs",
118
118
  "docs:check": "node scripts/sync-docs.mjs --check",
119
119
  "test:launcher": "go vet ./cmd/... && go test ./cmd/...",
120
+ "test:launch-arguments": "cargo build -p supercov && node scripts/launch-arguments-integration.mjs --binary target/debug/supercov",
120
121
  "test:sweep-target": "node scripts/sweep-target-test.mjs",
121
122
  "test:go-versions": "cargo build -p supercov-engine --tests && node scripts/go-version-matrix.mjs",
122
123
  "test:skip-guard": "node scripts/skip-guard-test.mjs",
123
124
  "test:windows-tls": "node scripts/windows-tls-test.mjs"
124
125
  },
125
126
  "optionalDependencies": {
126
- "@supercov/cli-darwin-arm64": "4.24.8",
127
- "@supercov/cli-darwin-x64": "4.24.8",
128
- "@supercov/cli-linux-arm64-gnu": "4.24.8",
129
- "@supercov/cli-linux-arm64-musl": "4.24.8",
130
- "@supercov/cli-linux-x64-gnu": "4.24.8",
131
- "@supercov/cli-linux-x64-musl": "4.24.8",
132
- "@supercov/cli-win32-arm64": "4.24.8",
133
- "@supercov/cli-win32-x64": "4.24.8"
127
+ "@supercov/cli-darwin-arm64": "4.26.0",
128
+ "@supercov/cli-darwin-x64": "4.26.0",
129
+ "@supercov/cli-linux-arm64-gnu": "4.26.0",
130
+ "@supercov/cli-linux-arm64-musl": "4.26.0",
131
+ "@supercov/cli-linux-x64-gnu": "4.26.0",
132
+ "@supercov/cli-linux-x64-musl": "4.26.0",
133
+ "@supercov/cli-win32-arm64": "4.26.0",
134
+ "@supercov/cli-win32-x64": "4.26.0"
134
135
  },
135
136
  "peerDependencies": {
136
137
  "@playwright/test": ">=1.55.0",
@@ -2,7 +2,7 @@ import fs, { appendFileSync, chmodSync, existsSync, mkdirSync, openSync, closeSy
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { syncBuiltinESMExports } from "node:module";
4
4
  import { threadId } from "node:worker_threads";
5
- import { dirname, resolve, sep } from "node:path";
5
+ import { basename, dirname, resolve, sep } from "node:path";
6
6
  import { Buffer } from "node:buffer";
7
7
 
8
8
  // In a container Supercov's `docker` launcher mounts the run's directory
@@ -159,6 +159,16 @@ export function appendEvidenceRecord(directory, prefix, payload) {
159
159
  // whole, or is not there yet and is compiled again. A file written beside the
160
160
  // cache's folders, not in one, is never taken for an old entry and removed.
161
161
  //
162
+ // Nor is an entry removed. Before it writes one, Playwright removes every
163
+ // cached file of that source, the entry another process has just written
164
+ // for the same content among them, and a process that had read that entry's
165
+ // code reads its source map only when a test is declared: in between, the
166
+ // map was gone, the test was placed by the compiled file's lines, and a
167
+ // `file:line` filter found no tests -- one test of a file, now and then, in
168
+ // a sealed suite whose containers start Playwright side by side. An entry is
169
+ // named by its source's content, so an old one is never read for new
170
+ // content; the cache is the run's own and goes with it.
171
+ //
162
172
  // Playwright compiles in two threads: the config and CommonJS files in the
163
173
  // process's own, ES modules in the thread its loader hooks run in, which has
164
174
  // its own `fs` and does not run `--import`. Each calls this. The partial
@@ -171,9 +181,16 @@ export function writePlaywrightCacheWhole() {
171
181
  return;
172
182
  cacheWritesWhole = true;
173
183
  const cacheFolder = resolve(transformCache) + sep;
184
+ const inCache = (file) => typeof file === "string" && resolve(file).startsWith(cacheFolder);
174
185
  const writeFileSync = fs.writeFileSync;
186
+ const rmSync = fs.rmSync;
187
+ fs.rmSync = function (file, ...rest) {
188
+ if (inCache(file) && !basename(file).startsWith(".writing-"))
189
+ return;
190
+ return rmSync.call(this, file, ...rest);
191
+ };
175
192
  fs.writeFileSync = function (file, ...rest) {
176
- if (typeof file !== "string" || !resolve(file).startsWith(cacheFolder))
193
+ if (!inCache(file))
177
194
  return writeFileSync.call(this, file, ...rest);
178
195
  const partial = resolve(transformCache, `.writing-${process.pid}-${threadId}-${randomUUID()}`);
179
196
  try {
@@ -181,7 +198,7 @@ export function writePlaywrightCacheWhole() {
181
198
  fs.renameSync(partial, file);
182
199
  }
183
200
  finally {
184
- fs.rmSync(partial, { force: true });
201
+ rmSync(partial, { force: true });
185
202
  }
186
203
  };
187
204
  syncBuiltinESMExports();
@@ -628,6 +628,10 @@ function inspectExports(value, depth = 0) {
628
628
  exportedValues.add(object);
629
629
  if (typeof value === "function")
630
630
  patchBuilder(value);
631
+ // What sits below this depth is never inspected: listing it cost every
632
+ // process a descriptor read per key of every export's members.
633
+ if (depth === 2)
634
+ return;
631
635
  for (const key of Reflect.ownKeys(object).slice(0, 200)) {
632
636
  if (key === "prototype" || key === "caller" || key === "callee")
633
637
  continue;
@@ -719,6 +723,12 @@ function injectChildEnvironment(method, args) {
719
723
  // every task aborted with ERR_MODULE_NOT_FOUND. launchSupervisor.js is
720
724
  // generated into the same .supercov directory as register.mjs.
721
725
  environment.NODE_OPTIONS = appendNodeImport(existingEnvironment?.NODE_OPTIONS ?? process.env.NODE_OPTIONS, new URL("./register.mjs", import.meta.url).href);
726
+ // The Playwright runner marked its children as not test workers; a process
727
+ // it forks from its worker entry is one (see register.mjs).
728
+ if (method === "fork" &&
729
+ environment.SUPERCOV_PLAYWRIGHT_WORKER !== undefined &&
730
+ /\/worker\/(?:workerProcessEntry|workerMain)\.js$/.test(String(args[0]).replaceAll("\\", "/")))
731
+ environment.SUPERCOV_PLAYWRIGHT_WORKER = "1";
722
732
  next[index] = { ...options, env: environment };
723
733
  if (typeof original === "function")
724
734
  next.splice(index + 1, 0, original);