@devries-cameron20 / t3code-1 / commits / cc5760a7a6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(scripts): report:renders works on machines without ~/.cache (#28274)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 31, 2026 at 21:50 UTC cc5760a7a6305be612d419b6f1f313bd4a20dc08
2 files changed +43 -4
scripts/render-metrics.test.ts
+41 -2
@@ -1,6 +1,45 @@
1 -import { describe, expect, it } from "vite-plus/test";
1 +// @effect-diagnostics nodeBuiltinImport:off - runOnce is a synchronous script, tested on a real temp dir.
2 +import * as NodeFS from "node:fs";
3 +import * as NodeOS from "node:os";
4 +import * as NodePath from "node:path";
5
3 -import { nondeterministic, renderComparison } from "./render-metrics.ts";
6 +import { describe, expect, it, vi } from "vite-plus/test";
7 +
8 +import { nondeterministic, renderComparison, runOnce } from "./render-metrics.ts";
9 +
10 +const mountReport = { commits: 2, renders: 10, components: { Row: 10 } };
11 +
12 +vi.mock("node:child_process", () => ({
13 + spawnSync: (
14 + _command: string,
15 + _args: string[],
16 + options: { env: { T3CODE_RENDER_REPORT_DIR: string } },
17 + ) => {
18 + NodeFS.writeFileSync(
19 + NodePath.join(options.env.T3CODE_RENDER_REPORT_DIR, "mount.json"),
20 + JSON.stringify(mountReport),
21 + );
22 + return { status: 0 };
23 + },
24 +}));
25 +
26 +describe("runOnce", () => {
27 + it("collects the scenario reports when HOME has no .cache, then removes its report dir", () => {
28 + const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-render-metrics-"));
29 + vi.stubEnv("HOME", home);
30 + vi.stubEnv("TMPDIR", home);
31 + vi.stubEnv("USERPROFILE", home);
32 + vi.stubEnv("TEMP", home);
33 + vi.stubEnv("TMP", home);
34 + try {
35 + expect(runOnce()).toEqual({ mount: mountReport });
36 + expect(NodeFS.readdirSync(home)).toEqual([]);
37 + } finally {
38 + vi.unstubAllEnvs();
39 + NodeFS.rmSync(home, { recursive: true, force: true });
40 + }
41 + });
42 +});
43
44 describe("nondeterministic", () => {
45 it("names only the scenarios whose counts differ between runs", () => {
scripts/render-metrics.ts
+2 -2
@@ -37,8 +37,8 @@ export type RenderMetrics = Readonly<Record<string, ScenarioReport>>;
37
38 const root = NodePath.resolve(import.meta.dirname, "..");
39
40 -function runOnce(): RenderMetrics {
41 - const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.homedir(), ".cache", "t3-renders-"));
40 +export function runOnce(): RenderMetrics {
41 + const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-renders-"));
42 try {
43 const result = NodeChildProcess.spawnSync("vp", ["test", "run", "--project", "renders"], {
44 cwd: NodePath.join(root, "apps/web"),