Skip to content
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -eu
PATH="${PATH:-/usr/bin:/bin}:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
export PATH

launcher_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
case $0 in
*/*) launcher_dir=${0%/*} ;;
*) launcher_dir=. ;;
esac
launcher_dir=$(CDPATH= cd "$launcher_dir" && pwd)
server_path=$launcher_dir/../mcp/server.mjs
cache_root=${XDG_CACHE_HOME:-${HOME:-}/.cache}
codex_resources=
Expand Down
16 changes: 13 additions & 3 deletions sdk/typescript/tests-ts/mcp-launcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { join } from "node:path";
import { expect, test } from "bun:test";
import { PLUGIN_ROOT } from "./plugin-root.js";

test("starts the packaged MCP server with managed Node and an empty PATH", async () => {
test("starts the packaged MCP server without running PATH utilities", async () => {
const node = Bun.which("node");
if (node === null)
throw new Error("Node is required for the MCP smoke test.");
Expand All @@ -30,6 +30,7 @@ test("starts the packaged MCP server with managed Node and an empty PATH", async
expect(config.env_vars).toContain("CODEX_MCP_NODE_PATH");
let managedNode = node;
const marker = join(root, "managed-node-used");
const dirnameMarker = join(root, "dirname-used");
if (process.platform !== "win32") {
managedNode = join(root, "managed-node");
const quote = (value: string) => `'${value.replaceAll("'", "'\\''")}'`;
Expand All @@ -38,6 +39,12 @@ test("starts the packaged MCP server with managed Node and an empty PATH", async
`#!/bin/sh\nprintf used > ${quote(marker)}\nexec ${quote(node)} "$@"\n`,
);
await chmod(managedNode, 0o700);
const dirname = join(root, "dirname");
await writeFile(
dirname,
`#!/bin/sh\nprintf used > ${quote(dirnameMarker)}\n`,
);
await chmod(dirname, 0o700);
}
const launcher = join(PLUGIN_ROOT, config.command);
const windows = process.platform === "win32";
Expand All @@ -49,7 +56,7 @@ test("starts the packaged MCP server with managed Node and an empty PATH", async
{
cwd: PLUGIN_ROOT,
env: {
PATH: "",
PATH: windows ? "" : root,
HOME: root,
USERPROFILE: root,
LOCALAPPDATA: root,
Expand Down Expand Up @@ -80,7 +87,10 @@ test("starts the packaged MCP server with managed Node and an empty PATH", async
expect(JSON.parse(result.stdout).result.serverInfo.name).toBe(
"codex-security",
);
if (!windows) expect(await readFile(marker, "utf8")).toBe("used");
if (!windows) {
expect(await readFile(marker, "utf8")).toBe("used");
expect(await Bun.file(dirnameMarker).exists()).toBe(false);
}
} finally {
await rm(root, { recursive: true, force: true });
}
Expand Down
Loading