Files
millionco__react-doctor/packages/react-doctor/tests/resolve-worker-telemetry.test.ts
Ray Arayilakath 627f9ca4b3 perf: speed up large-repo scans + fix dead-code drop under supply-chain (#903)
Integrates the 7 large-repo speedup PRs (#894–#900) plus the dead-code reworks
done on top of them.

Headline (measured on Sentry, supply-chain on): full scan ~142s → ~40s (3.6x),
with dead-code findings fully intact.

- deslop: skip the analysis passes react-doctor discards — the semantic
  TS-Program pass and the code-quality detectors (duplicate-block/complexity/
  feature-flag/TS-smell/private-type-leak/re-export-cycle), gated behind a new
  `reportCodeQuality` flag (default on for deslop standalone). ~8.5x faster
  dead-code on a large repo, byte-identical consumed findings, locked by a
  parity test.
- Dead-code runs sequentially by default with a file-count-scaled timeout,
  fixing a regression where overlapping it with lint oversubscribed the cores
  and silently dropped all dead-code findings under supply-chain. Opt-in
  `REACT_DOCTOR_DEAD_CODE_OVERLAP=on` now splits the core budget instead of
  doubling it.
- Plus the merged PRs: memory-budgeted worker cap (#896), bounded-phase hard
  timeouts (#899), supply-chain∥lint overlap (#894), per-file lint cache (#900),
  deterministic diagnostics (#897), module-cache dedup (#895).

CI: full test matrix (macOS/Ubuntu 20–26/Windows), build, typecheck, lint, and
react-doctor smoke all green. The 1s "CodeQL" check is the pre-existing
code-scanning-alert gate (main's CodeQL analysis is green); no security-relevant
code changed.
2026-06-19 19:25:51 -07:00

35 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vite-plus/test";
import { resolveWorkerTelemetry } from "../src/cli/utils/resolve-worker-telemetry.js";
describe("resolveWorkerTelemetry", () => {
it("reports the resolved auto count and parallel=true when no count was pinned", () => {
// The headline case: auto path, caller pinned nothing — telemetry must still
// see the real worker count and read parallel, not fall back to false.
expect(resolveWorkerTelemetry(8, undefined)).toEqual({ workerCount: 8, parallel: true });
});
it("reports parallel=false for a single-worker (serial) run", () => {
expect(resolveWorkerTelemetry(1, undefined)).toEqual({ workerCount: 1, parallel: false });
// A pinned serial run (`inspect({ concurrency: 1 })`) is NOT parallel, even
// though a count was pinned — the old `concurrency !== undefined` proxy got
// this wrong.
expect(resolveWorkerTelemetry(1, 1)).toEqual({ workerCount: 1, parallel: false });
});
it("prefers the resolved count over the pin", () => {
expect(resolveWorkerTelemetry(12, 4)).toEqual({ workerCount: 12, parallel: true });
});
it("falls back to the pin when no resolved count is available (stale cache / failure path)", () => {
expect(resolveWorkerTelemetry(undefined, 4)).toEqual({ workerCount: 4, parallel: true });
expect(resolveWorkerTelemetry(undefined, 1)).toEqual({ workerCount: 1, parallel: false });
});
it("reports an undefined count and parallel=false when neither source knows it", () => {
expect(resolveWorkerTelemetry(undefined, undefined)).toEqual({
workerCount: undefined,
parallel: false,
});
});
});