Skip to content
Open
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
5 changes: 3 additions & 2 deletions mcp-package/bin/fetch-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ function isStale(targetDir, version) {
* and which assets were downloaded (empty when everything was already there).
*/
async function ensureEngine(version, targetDir, options = {}) {
const assets = requiredAssets(options.platform, options.arch);
const { platform = os.platform(), arch = os.arch() } = options;
const assets = requiredAssets(platform, arch);
if (assets.length === 0) {
throw new Error(`no CodeGraph engine is published for ${os.platform()}-${os.arch()}`);
throw new Error(`no CodeGraph engine is published for ${platform}-${arch}`);
}

fs.mkdirSync(targetDir, { recursive: true });
Expand Down
28 changes: 28 additions & 0 deletions mcp-package/test/fetch-engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,34 @@ async function run() {
// someone else's binary.
check(platformBinaryName("linux", "riscv64") === null, "an unbuilt arch resolves to nothing");
check(requiredAssets("linux", "riscv64").length === 0, "an unpublished pair needs no assets");

// --- unsupported installs report the requested platform and arch -----
{
const dir = scratch();
const targetDir = path.join(dir, "engine");
const { server, baseUrl } = await startRelease({});
try {
for (const [options, target] of [
[{ platform: "freebsd", arch: "x64" }, "freebsd-x64"],
[{ platform: "linux", arch: "riscv64" }, "linux-riscv64"],
[{ platform: "win32", arch: "arm" }, "win32-arm"],
[{ platform: "freebsd" }, `freebsd-${os.arch()}`],
[{ arch: "riscv64" }, `${os.platform()}-riscv64`],
]) {
let threw = null;
await ensureEngine(VERSION, targetDir, { ...options, baseUrl }).catch((e) => (threw = e));
check(
threw !== null && threw.message === `no CodeGraph engine is published for ${target}`,
`an unsupported install reports ${target}`
);
check(!fs.existsSync(targetDir), `${target} is rejected before creating the install directory`);
}
} finally {
server.close();
fs.rmSync(dir, { recursive: true, force: true });
}
}

// Every name the mapping can return has to be a name the release publishes,
// or an install fetches a 404.
for (const [p, a] of [
Expand Down