Skip to content

Commit cddaba2

Browse files
committed
test(server): verify caching before the CLI bundle loads
1 parent 53e67a5 commit cddaba2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/server/src/cliCompileCache.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ it.live("enables CLI caching while respecting overrides and unavailable storage"
1212
const fs = yield* FileSystem.FileSystem;
1313
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1414
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-cli-cache-test-" });
15-
const report = `import { getCompileCacheDir } from 'node:module'; process.once('exit', () => console.error('CACHE=' + (getCompileCacheDir() ?? 'disabled')));`;
15+
const report = `import { getCompileCacheDir, registerHooks } from 'node:module'; registerHooks({ resolve(specifier, context, nextResolve) { if (specifier === './binCli.ts') console.error('CACHE=' + (getCompileCacheDir() ?? 'disabled')); return nextResolve(specifier, context); } });`;
1616
const run = Effect.fn("cliCompileCache.test.run")(function* (env: Record<string, string>) {
1717
const child = yield* spawner.spawn(
1818
ChildProcess.make(
@@ -47,7 +47,12 @@ it.live("enables CLI caching while respecting overrides and unavailable storage"
4747
}, Effect.scoped);
4848
const normal = yield* run({});
4949
expect(normal.exitCode).toBe(0);
50-
expect(normal.stderr).not.toContain("CACHE=disabled");
50+
expect(normal.stderr.replaceAll("\\", "/")).toContain(
51+
`CACHE=${root}/cache/t3code/compile-cache`.replaceAll("\\", "/"),
52+
);
53+
const appImage = yield* run({ APPIMAGE: `${root}/T3Code.AppImage` });
54+
expect(appImage.exitCode).toBe(0);
55+
expect(appImage.stderr).toContain("CACHE=disabled");
5156
const existing = yield* run({ NODE_COMPILE_CACHE: `${root}/explicit` });
5257
expect(existing.exitCode).toBe(0);
5358
expect(existing.stderr.replaceAll("\\", "/")).toContain(

0 commit comments

Comments
 (0)