Skip to content

Commit 3a4d78f

Browse files
only21milclaude
andcommitted
fix(scripts): report:renders starts on Windows without a vp shim
runOnce spawned bare `vp`, which a shell-less spawn cannot resolve on Windows when the only vp is node_modules\.bin\vp.cmd, so the run failed with `exit null`. It now launches through vitePlusCommand, as check:changed does since #24164. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 71c2d3a commit 3a4d78f

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎scripts/render-metrics.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import * as NodePath from "node:path";
55

66
import { describe, expect, it, vi } from "vite-plus/test";
77

8+
import { vitePlusCommand } from "./check-changed-command.ts";
89
import { nondeterministic, renderComparison, runOnce } from "./render-metrics.ts";
910

1011
const mountReport = { commits: 2, renders: 10, components: { Row: 10 } };
12+
const spawned: Array<[command: string, args: string[]]> = [];
1113

1214
vi.mock("node:child_process", () => ({
1315
spawnSync: (
14-
_command: string,
15-
_args: string[],
16+
command: string,
17+
args: string[],
1618
options: { env: { T3CODE_RENDER_REPORT_DIR: string } },
1719
) => {
20+
spawned.push([command, args]);
1821
NodeFS.writeFileSync(
1922
NodePath.join(options.env.T3CODE_RENDER_REPORT_DIR, "mount.json"),
2023
JSON.stringify(mountReport),
@@ -34,6 +37,9 @@ describe("runOnce", () => {
3437
try {
3538
expect(runOnce()).toEqual({ mount: mountReport });
3639
expect(NodeFS.readdirSync(home)).toEqual([]);
40+
spawned.length = 0;
41+
runOnce("win32");
42+
expect(spawned).toEqual([vitePlusCommand(["test", "run", "--project", "renders"], "win32")]);
3743
} finally {
3844
vi.unstubAllEnvs();
3945
NodeFS.rmSync(home, { recursive: true, force: true });

‎scripts/render-metrics.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as NodeFS from "node:fs";
44
import * as NodeOS from "node:os";
55
import * as NodePath from "node:path";
66

7+
import { vitePlusCommand } from "./check-changed-command.ts";
8+
79
const HELP = `Usage:
810
node scripts/render-metrics.ts run [--out <file>] [--runs <n>]
911
node scripts/render-metrics.ts compare <before.json> <after.json> [--top <n>]
@@ -37,10 +39,17 @@ export type RenderMetrics = Readonly<Record<string, ScenarioReport>>;
3739

3840
const root = NodePath.resolve(import.meta.dirname, "..");
3941

40-
export function runOnce(): RenderMetrics {
42+
export function runOnce(
43+
// oxlint-disable-next-line t3code/no-global-process-runtime -- Standalone Node tooling has no Effect runtime; tests pass the platform explicitly.
44+
platform: NodeJS.Platform = process.platform,
45+
): RenderMetrics {
4146
const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-renders-"));
4247
try {
43-
const result = NodeChildProcess.spawnSync("vp", ["test", "run", "--project", "renders"], {
48+
const [command, commandArgs] = vitePlusCommand(
49+
["test", "run", "--project", "renders"],
50+
platform,
51+
);
52+
const result = NodeChildProcess.spawnSync(command, commandArgs, {
4453
cwd: NodePath.join(root, "apps/web"),
4554
env: { ...process.env, T3CODE_RENDER_REPORT_DIR: directory },
4655
stdio: ["ignore", "inherit", "inherit"],
@@ -119,7 +128,7 @@ if (import.meta.main) {
119128
const [command, ...args] = process.argv.slice(2);
120129
if (command === "run") {
121130
const runs = Number(option(args, "--runs") ?? 3);
122-
const results = Array.from({ length: runs }, runOnce);
131+
const results = Array.from({ length: runs }, () => runOnce());
123132
const unstable = nondeterministic(results);
124133
if (unstable.length) {
125134
for (const scenario of unstable) {

0 commit comments

Comments
 (0)