Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/cli/ocx-launcher-source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("ocx.mjs package launcher (source invariants)", () => {
// Path and source come from one resolution, so the marker cannot describe another binary.
expect(source).toContain("const bunRuntime = resolveBun({ allowInstall: !codexCliUpdateInspection });");
expect(source).toContain("const bun = bunRuntime.path;");
expect(source).toContain('return { path: bin, source: "bundled" };');
expect(source).toContain('return { path: bin, source: "bundled", version: bundledBunVersion(bunDir) };');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cover the post-install bundled return

When the bundled binary is initially unusable but install.js repairs it, resolveBun takes the second bundled return at bin/ocx.mjs:1061. This toContain is already satisfied by the fast-path return at line 1052, so the post-install branch could again omit version, pass this oracle, and send undefined to scopeTranspilerCacheToRuntime; assert both occurrences or scope an assertion to each branch.

Useful? React with 👍 / 👎.


// The launcher's literal name must match the TypeScript constant it mirrors.
expect(runtimeSource).toContain('export const BUN_RUNTIME_SOURCE_ENV = "OCX_BUN_RUNTIME_SOURCE";');
Expand Down Expand Up @@ -138,7 +138,8 @@ describe("ocx.mjs package launcher (source invariants)", () => {
*/
test("the inspection child does not inherit a duplicate copy of the snapshotted values", () => {
expect(source).toContain("const inheritedEnv = { ...process.env };");
expect(source).toContain("...inheritedEnv,");
// The de-duplicated environment reaches the child; only its transpiler cache is scoped (#7362).
expect(source).toContain("...scopeTranspilerCacheToRuntime(inheritedEnv, bunRuntime.version, join),");
// Windows spells the variable `Path` in practice, so an upper-case-only delete would
// leave the duplicate behind. The match must be on the lowercase form of every key.
expect(source).toContain("if (snapshotted.has(name.toLowerCase())) delete inheritedEnv[name];");
Expand All @@ -153,6 +154,8 @@ describe("ocx.mjs package launcher (source invariants)", () => {
const spawnStart = source.indexOf("const child = spawn(bun, [cliPath,");
expect(spawnStart).toBeGreaterThan(-1);
expect(source.slice(spawnStart)).not.toContain("...process.env,");
expect(source.slice(spawnStart, source.indexOf("});", spawnStart)))
.toContain("...scopeTranspilerCacheToRuntime(inheritedEnv, bunRuntime.version, join),");
});

/**
Expand Down
Loading