Skip to content
Merged
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
9 changes: 8 additions & 1 deletion test/engines.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ import { fileURLToPath } from "node:url";
import { spawn } from "node:child_process";
import test from "node:test";

import { ENGINES, agentLaunchArgs, aiExecArgs, engineBinOverride, exitReason, isInstalled, openPassthrough, pickAiEngine, ranOk, resolveEngine, runCmd } from "../src/engines.mjs";
// engines.mjs applies MOSHCODE_ENGINE_BIN_<KEY> to ENGINES.*.bin at import, and
// run() hands process.env to every child. An override exported in the shell
// running the suite (a local codex build, say) would otherwise swap the stubs
// below for that build. Scrub them first; the override tests set their own.
for (const name of Object.keys(process.env)) {
if (name.startsWith("MOSHCODE_ENGINE_BIN_")) delete process.env[name];
}
const { ENGINES, agentLaunchArgs, aiExecArgs, engineBinOverride, exitReason, isInstalled, openPassthrough, pickAiEngine, ranOk, resolveEngine, runCmd } = await import("../src/engines.mjs");

const BIN = fileURLToPath(new URL("../bin/moshcode.mjs", import.meta.url));
// The autonomous-session bypass flags each engine declares (engine.agentArgs).
Expand Down
8 changes: 8 additions & 0 deletions test/mcp.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import { parseMcp } from "../src/integrations.mjs";

const BIN = fileURLToPath(new URL("../bin/moshcode.mjs", import.meta.url));

// The fan-out test below puts stub engines on PATH and hands process.env to the
// CLI. A MOSHCODE_ENGINE_BIN_<KEY> exported in the shell running the suite
// would send that engine's `mcp add` to the real build instead of the stub —
// writing into the operator's own engine config.
for (const name of Object.keys(process.env)) {
if (name.startsWith("MOSHCODE_ENGINE_BIN_")) delete process.env[name];
}

test("deriveName pulls a sane name from a remote host", () => {
assert.equal(deriveName("https://mcp.sentry.dev/mcp"), "sentry");
assert.equal(deriveName("https://api.githubcopilot.com/mcp/"), "githubcopilot");
Expand Down
7 changes: 7 additions & 0 deletions test/tui-prd-errors.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const replied = (out) => strip(out).split("to leave")[1] || "";
// the child nothing else.
const NO_ENGINES = mkdtempSync(join(tmpdir(), "moshcode-no-engines-"));

// An empty PATH is not the whole of "no engines": MOSHCODE_ENGINE_BIN_<KEY>
// names an engine by absolute path, so one exported in the shell running the
// suite made codex "installed" here and /prd launched that real build.
for (const name of Object.keys(process.env)) {
if (name.startsWith("MOSHCODE_ENGINE_BIN_")) delete process.env[name];
}

function runTui(input, cwd) {
return new Promise((resolve, reject) => {
const child = spawn(process.execPath, [BIN], {
Expand Down
Loading