Skip to content

Commit f9560e5

Browse files
fix(installer): report the requested unsupported platform
1 parent 489ccf1 commit f9560e5

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

mcp-package/bin/fetch-engine.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ function isStale(targetDir, version) {
387387
* and which assets were downloaded (empty when everything was already there).
388388
*/
389389
async function ensureEngine(version, targetDir, options = {}) {
390-
const assets = requiredAssets(options.platform, options.arch);
390+
const { platform = os.platform(), arch = os.arch() } = options;
391+
const assets = requiredAssets(platform, arch);
391392
if (assets.length === 0) {
392-
throw new Error(`no CodeGraph engine is published for ${os.platform()}-${os.arch()}`);
393+
throw new Error(`no CodeGraph engine is published for ${platform}-${arch}`);
393394
}
394395

395396
fs.mkdirSync(targetDir, { recursive: true });

mcp-package/test/fetch-engine.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,34 @@ async function run() {
474474
// someone else's binary.
475475
check(platformBinaryName("linux", "riscv64") === null, "an unbuilt arch resolves to nothing");
476476
check(requiredAssets("linux", "riscv64").length === 0, "an unpublished pair needs no assets");
477+
478+
// --- unsupported installs report the requested platform and arch -----
479+
{
480+
const dir = scratch();
481+
const targetDir = path.join(dir, "engine");
482+
const { server, baseUrl } = await startRelease({});
483+
try {
484+
for (const [options, target] of [
485+
[{ platform: "freebsd", arch: "x64" }, "freebsd-x64"],
486+
[{ platform: "linux", arch: "riscv64" }, "linux-riscv64"],
487+
[{ platform: "win32", arch: "arm" }, "win32-arm"],
488+
[{ platform: "freebsd" }, `freebsd-${os.arch()}`],
489+
[{ arch: "riscv64" }, `${os.platform()}-riscv64`],
490+
]) {
491+
let threw = null;
492+
await ensureEngine(VERSION, targetDir, { ...options, baseUrl }).catch((e) => (threw = e));
493+
check(
494+
threw !== null && threw.message === `no CodeGraph engine is published for ${target}`,
495+
`an unsupported install reports ${target}`
496+
);
497+
check(!fs.existsSync(targetDir), `${target} is rejected before creating the install directory`);
498+
}
499+
} finally {
500+
server.close();
501+
fs.rmSync(dir, { recursive: true, force: true });
502+
}
503+
}
504+
477505
// Every name the mapping can return has to be a name the release publishes,
478506
// or an install fetches a 404.
479507
for (const [p, a] of [

0 commit comments

Comments
 (0)