Repository navigation
Expand file tree
/
Copy pathruntimeArtifacts.test.ts
More file actions
528 lines (488 loc) · 23.2 KB
/
Copy pathruntimeArtifacts.test.ts
File metadata and controls
528 lines (488 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
import {
existsSync,
mkdtempSync,
mkdirSync,
readFileSync,
rmSync,
statSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { createHash } from "node:crypto";
import { spawnSync } from "node:child_process";
import { c as createTar } from "tar";
import { afterEach, describe, expect, it, onTestFinished, vi } from "vitest";
import {
defaultRuntimeCacheRoot,
ensureRuntimeBundle,
getRuntimePackageName,
getRuntimePlatform,
getRuntimeReleaseAssetName,
materializeRuntimeBundle,
} from "../src/runtimeArtifacts.js";
import { COPILOT_CLI_USE_NPM_PACKAGE, COPILOT_CLI_VERSION } from "../src/cliVersion.js";
import { downloadVerifiedReleaseAsset, ensureCopilotPackage } from "../scripts/releaseArtifacts.js";
import { getLegacyCliPathForTests } from "./e2e/harness/sdkTestContext.js";
import * as runtimeLayout from "../../scripts/runtime-layout.mjs";
describe("defaultRuntimeCacheRoot", () => {
it.each([
[
"darwin",
"/home/test",
{},
join("/home/test", "Library", "Caches", "github-copilot-sdk", "runtime"),
],
["linux", "/home/test", {}, join("/home/test", ".cache", "github-copilot-sdk", "runtime")],
[
"linux",
"/home/test",
{ XDG_CACHE_HOME: "/cache" },
join("/cache", "github-copilot-sdk", "runtime"),
],
[
"win32",
"C:\\Users\\test",
{ LOCALAPPDATA: "C:\\Users\\test\\AppData\\Local" },
join("C:\\Users\\test\\AppData\\Local", "github-copilot-sdk", "runtime"),
],
])("uses the %s user cache directory", (platform, home, environment, expected) => {
expect(defaultRuntimeCacheRoot(platform, home, environment)).toBe(expected);
});
});
describe("release runtime selection", () => {
it("keeps the compiled CLI version aligned with package metadata", () => {
const packageJson = JSON.parse(
readFileSync(join(import.meta.dirname, "../package.json"), "utf8")
);
expect(COPILOT_CLI_VERSION).toBe(packageJson.copilotCliVersion);
// lgtm[js/trivial-conditional] This generated constant is true for internal canary builds.
if (COPILOT_CLI_USE_NPM_PACKAGE) {
expect(packageJson.dependencies["@github/copilot"]).toBe(COPILOT_CLI_VERSION);
} else {
expect(packageJson.dependencies).not.toHaveProperty("@github/copilot");
}
});
it("can pin an internal npm package without contacting GitHub Releases", () => {
const root = mkdtempSync(join(tmpdir(), "copilot-cli-version-"));
mkdirSync(join(root, "scripts"), { recursive: true });
mkdirSync(join(root, "src"), { recursive: true });
writeFileSync(join(root, "package.json"), "{}\n");
writeFileSync(
join(root, "scripts", "set-cli-version.js"),
readFileSync(join(import.meta.dirname, "../scripts/set-cli-version.js"))
);
const result = spawnSync(
process.execPath,
[
join(root, "scripts", "set-cli-version.js"),
"9.9.9-canary.r123.gabcdef0.signed",
"--npm-package",
],
{ encoding: "utf8" }
);
expect(result.status, result.stderr).toBe(0);
expect(JSON.parse(readFileSync(join(root, "package.json"), "utf8"))).toMatchObject({
copilotCliVersion: "9.9.9-canary.r123.gabcdef0.signed",
});
expect(existsSync(join(root, "copilot-cli.json"))).toBe(false);
expect(readFileSync(join(root, "src", "cliVersion.ts"), "utf8")).toContain(
"COPILOT_CLI_USE_NPM_PACKAGE = true"
);
});
it("can pin a pre-acquired package while preserving embedded runtime packaging", () => {
const root = mkdtempSync(join(tmpdir(), "copilot-local-package-version-"));
mkdirSync(join(root, "scripts"), { recursive: true });
mkdirSync(join(root, "src"), { recursive: true });
writeFileSync(join(root, "package.json"), "{}\n");
writeFileSync(
join(root, "scripts", "set-cli-version.js"),
readFileSync(join(import.meta.dirname, "../scripts/set-cli-version.js"))
);
const result = spawnSync(
process.execPath,
[
join(root, "scripts", "set-cli-version.js"),
"9.9.9-unstable.r123.gabcdef0",
"--local-package",
],
{ encoding: "utf8" }
);
expect(result.status, result.stderr).toBe(0);
expect(readFileSync(join(root, "src", "cliVersion.ts"), "utf8")).toContain(
"COPILOT_CLI_USE_NPM_PACKAGE = false"
);
});
it.each([
["darwin", "arm64", false, "darwin-arm64"],
["darwin", "x64", false, "darwin-x64"],
["linux", "arm64", false, "linux-arm64"],
["linux", "x64", true, "linuxmusl-x64"],
["win32", "arm64", false, "win32-arm64"],
])("maps %s/%s to %s", (platform, arch, musl, expected) => {
expect(getRuntimePlatform(platform, arch, musl)).toBe(expected);
});
it("uses the platform npm tarball published in the CLI release", () => {
expect(getRuntimeReleaseAssetName("1.2.3-4", "linux-x64")).toBe(
"github-copilot-1.2.3-4-linux-x64.tgz"
);
});
it("uses the SDK platform package namespace", () => {
expect(getRuntimePackageName("linux-x64")).toBe("@github/copilot-sdk-linux-x64");
});
});
describe("materializeRuntimeBundle", () => {
afterEach(() => vi.unstubAllEnvs());
it("materializes an adjacent pair from an absent cache with a stripped environment", () => {
const sourceDir = mkdtempSync(join(tmpdir(), "copilot-runtime-source-"));
const cacheRoot = join(sourceDir, "absent-cache");
const emptyPath = join(sourceDir, "empty-path");
mkdirSync(emptyPath);
const platform = process.platform === "win32" ? "win32-x64" : "test-platform";
const wrapperName = platform.startsWith("win32")
? "copilot-runtime.exe"
: "copilot-runtime";
const prebuilds = join(sourceDir, "prebuilds", platform);
const wrapper = join(prebuilds, wrapperName);
const runtimeNode = join(prebuilds, "runtime.node");
mkdirSync(prebuilds, { recursive: true });
writeFileSync(wrapper, "wrapper");
writeFileSync(runtimeNode, "runtime");
mkdirSync(join(sourceDir, "ripgrep", "bin", platform), { recursive: true });
writeFileSync(join(sourceDir, "ripgrep", "bin", platform, "rg"), "ripgrep", {
mode: 0o755,
});
mkdirSync(join(sourceDir, "definitions"), { recursive: true });
writeFileSync(join(sourceDir, "definitions", "future.json"), "{}");
mkdirSync(join(sourceDir, "copilot-sdk"), { recursive: true });
writeFileSync(join(sourceDir, "copilot-sdk", "extension.js"), "extension SDK");
mkdirSync(join(sourceDir, "preloads"), { recursive: true });
writeFileSync(join(sourceDir, "preloads", "extension_bootstrap.mjs"), "bootstrap");
writeFileSync(join(sourceDir, "app.js"), "excluded");
writeFileSync(join(sourceDir, "copilot"), "excluded");
writeFileSync(join(sourceDir, "copilot.exe"), "excluded");
writeFileSync(join(sourceDir, "LICENSE.md"), "excluded");
writeFileSync(join(sourceDir, "README.md"), "excluded");
vi.stubEnv("PATH", emptyPath);
vi.stubEnv("COPILOT_CLI_PATH", undefined);
vi.stubEnv("COPILOT_RUNTIME_HOST_COMMAND", undefined);
vi.stubEnv("COPILOT_RUNTIME_PROVIDER_LIB", undefined);
expect(process.env.COPILOT_CLI_PATH).toBeUndefined();
expect(process.env.COPILOT_RUNTIME_HOST_COMMAND).toBeUndefined();
expect(process.env.COPILOT_RUNTIME_PROVIDER_LIB).toBeUndefined();
const installedWrapper = materializeRuntimeBundle(
{ packageRoot: sourceDir, platform },
cacheRoot
);
const installDir = resolve(dirname(installedWrapper), "..", "..");
expect(readFileSync(installedWrapper, "utf8")).toBe("wrapper");
expect(readFileSync(join(installDir, "prebuilds", platform, "runtime.node"), "utf8")).toBe(
"runtime"
);
expect(readFileSync(join(installDir, "ripgrep", "bin", platform, "rg"), "utf8")).toBe(
"ripgrep"
);
expect(readFileSync(join(installDir, "copilot-sdk", "extension.js"), "utf8")).toBe(
"extension SDK"
);
expect(readFileSync(join(installDir, "preloads", "extension_bootstrap.mjs"), "utf8")).toBe(
"bootstrap"
);
expect(existsSync(join(installDir, "app.js"))).toBe(false);
expect(existsSync(join(installDir, "copilot"))).toBe(false);
expect(existsSync(join(installDir, "copilot.exe"))).toBe(false);
expect(existsSync(join(installDir, "LICENSE.md"))).toBe(false);
expect(existsSync(join(installDir, "README.md"))).toBe(false);
if (process.platform !== "win32") {
expect(statSync(installedWrapper).mode & 0o111).not.toBe(0);
expect(
statSync(join(installDir, "ripgrep", "bin", platform, "rg")).mode & 0o111
).not.toBe(0);
}
});
it("fails clearly when the package has no runtime.node", () => {
const sourceDir = mkdtempSync(join(tmpdir(), "copilot-runtime-missing-node-"));
const platform = process.platform === "win32" ? "win32-x64" : "test-platform";
const wrapperName = platform.startsWith("win32")
? "copilot-runtime.exe"
: "copilot-runtime";
const prebuilds = join(sourceDir, "prebuilds", platform);
const wrapper = join(prebuilds, wrapperName);
mkdirSync(prebuilds, { recursive: true });
writeFileSync(wrapper, "wrapper");
expect(() =>
materializeRuntimeBundle(
{
packageRoot: sourceDir,
platform,
},
join(sourceDir, "cache")
)
).toThrow(/Copilot runtime\.node not found/);
});
});
describe("ensureRuntimeBundle", () => {
it("resolves the installed platform runtime without network access", async () => {
const root = mkdtempSync(join(tmpdir(), "copilot-packaged-runtime-"));
const nodeModules = join(root, "node_modules");
const platform = "linux-x64";
const packageRoot = join(nodeModules, ...getRuntimePackageName(platform).split("/"));
const prebuilds = join(packageRoot, "prebuilds", platform);
mkdirSync(prebuilds, { recursive: true });
writeFileSync(join(packageRoot, "package.json"), "{}");
writeFileSync(join(prebuilds, "copilot-runtime"), "wrapper");
writeFileSync(join(prebuilds, "runtime.node"), "runtime");
mkdirSync(join(packageRoot, "schemas"));
writeFileSync(join(packageRoot, "schemas", "api.schema.json"), "{}");
const fetcher = vi.fn(() => {
throw new Error("runtime resolution must not fetch");
});
vi.stubGlobal("fetch", fetcher);
const runtimePath = await ensureRuntimeBundle(COPILOT_CLI_VERSION, {
packageSearchPaths: [nodeModules],
platform,
});
expect(runtimePath).toBe(join(prebuilds, "copilot-runtime"));
expect(readFileSync(join(dirname(runtimePath), "runtime.node"), "utf8")).toBe("runtime");
expect(fetcher).not.toHaveBeenCalled();
vi.unstubAllGlobals();
});
it("fails clearly when the platform package is not installed", async () => {
await expect(
ensureRuntimeBundle(COPILOT_CLI_VERSION, {
packageSearchPaths: [],
platform: "linux-x64",
})
).rejects.toThrow(
"Could not resolve @github/copilot-sdk-linux-x64. Reinstall @github/copilot-sdk"
);
});
});
describe("release package acquisition", () => {
it("uses an ambient acquired package only for its exact runtime version", async () => {
const root = mkdtempSync(join(tmpdir(), "copilot-runtime-environment-"));
const platform = "linux-x64";
const packageRoot = join(root, platform);
const prebuilds = join(packageRoot, "prebuilds", platform);
mkdirSync(prebuilds, { recursive: true });
writeFileSync(
join(packageRoot, "package.json"),
JSON.stringify({ version: COPILOT_CLI_VERSION })
);
writeFileSync(join(packageRoot, "app.js"), "legacy CLI");
writeFileSync(join(prebuilds, "runtime.node"), "runtime");
const fetcher = vi.fn(() => {
throw new Error("matching ambient runtime resolution must not fetch");
});
const environment = {
...process.env,
COPILOT_SDK_RUNTIME_PACKAGE_DIR: root,
};
await expect(
ensureCopilotPackage(COPILOT_CLI_VERSION, {
environment,
fetch: fetcher,
platform,
})
).resolves.toBe(packageRoot);
expect(readFileSync(join(packageRoot, "app.js"), "utf8")).toBe("legacy CLI");
expect(fetcher).not.toHaveBeenCalled();
});
it("resolves the legacy E2E CLI from the matching acquired package", async () => {
const root = mkdtempSync(join(tmpdir(), "copilot-legacy-runtime-"));
const platform = getRuntimePlatform();
const packageRoot = join(root, platform);
mkdirSync(join(packageRoot, "prebuilds", platform), { recursive: true });
writeFileSync(
join(packageRoot, "package.json"),
JSON.stringify({ version: COPILOT_CLI_VERSION })
);
writeFileSync(join(packageRoot, "app.js"), "legacy CLI");
writeFileSync(join(packageRoot, "prebuilds", platform, "runtime.node"), "runtime");
vi.stubEnv("COPILOT_SDK_RUNTIME_PACKAGE_DIR", root);
vi.stubEnv("COPILOT_RUNTIME_SOURCE", "published");
vi.stubEnv("COPILOT_LEGACY_CLI_PATH", undefined);
try {
await expect(getLegacyCliPathForTests()).resolves.toBe(join(packageRoot, "app.js"));
} finally {
vi.unstubAllEnvs();
}
});
it("resolves the legacy E2E CLI from checkout artifacts without an explicit source flag", async () => {
const root = mkdtempSync(join(tmpdir(), "copilot-legacy-checkout-"));
const platform = getRuntimePlatform();
const acquiredRoot = join(root, "acquired");
const packageRoot = join(acquiredRoot, platform);
mkdirSync(join(packageRoot, "prebuilds", platform), { recursive: true });
writeFileSync(
join(packageRoot, "package.json"),
JSON.stringify({ version: COPILOT_CLI_VERSION })
);
writeFileSync(join(packageRoot, "app.js"), "published CLI");
writeFileSync(
join(packageRoot, "prebuilds", platform, "runtime.node"),
"published runtime"
);
const legacyCliPath = join(root, "app.js");
writeFileSync(legacyCliPath, "checkout CLI");
const findRuntimeRoot = vi.spyOn(runtimeLayout, "findRuntimeRoot").mockReturnValue(root);
vi.stubEnv("COPILOT_RUNTIME_SOURCE", undefined);
vi.stubEnv("COPILOT_LEGACY_CLI_PATH", legacyCliPath);
vi.stubEnv("COPILOT_SDK_RUNTIME_PACKAGE_DIR", acquiredRoot);
try {
await expect(getLegacyCliPathForTests()).resolves.toBe(legacyCliPath);
} finally {
findRuntimeRoot.mockRestore();
vi.unstubAllEnvs();
rmSync(root, { recursive: true, force: true });
}
});
it("ignores an ambient acquired package for a different requested version", async () => {
const sourceRoot = mkdtempSync(join(tmpdir(), "copilot-runtime-version-guard-"));
const acquiredRoot = join(sourceRoot, "acquired");
const platform = "linux-x64";
const acquiredPackageRoot = join(acquiredRoot, platform);
const acquiredPrebuilds = join(acquiredPackageRoot, "prebuilds", platform);
mkdirSync(acquiredPrebuilds, { recursive: true });
writeFileSync(
join(acquiredPackageRoot, "package.json"),
JSON.stringify({ version: COPILOT_CLI_VERSION })
);
writeFileSync(join(acquiredPrebuilds, "runtime.node"), "acquired runtime");
const packageRoot = join(sourceRoot, "package");
const prebuilds = join(packageRoot, "prebuilds", platform);
mkdirSync(prebuilds, { recursive: true });
writeFileSync(join(prebuilds, "runtime.node"), "controlled runtime");
mkdirSync(join(packageRoot, "schemas"), { recursive: true });
writeFileSync(join(packageRoot, "schemas", "api.schema.json"), "{}");
const archivePath = join(sourceRoot, "runtime.tgz");
await createTar({ cwd: sourceRoot, file: archivePath, gzip: true }, ["package"]);
const archive = readFileSync(archivePath);
const version = "1.2.3-controlled.1";
const assetName = getRuntimeReleaseAssetName(version, platform);
const checksum = createHash("sha256").update(archive).digest("hex");
const fetcher = vi.fn(async (input: string | URL | Request) =>
String(input).endsWith("/SHA256SUMS.txt")
? new Response(`${checksum} ${assetName}\n`)
: new Response(archive)
);
const resolved = await ensureCopilotPackage(version, {
cacheRoot: join(sourceRoot, "cache"),
environment: {
...process.env,
COPILOT_SDK_RUNTIME_PACKAGE_DIR: acquiredRoot,
},
fetch: fetcher,
platform,
});
expect(resolved).not.toBe(acquiredPackageRoot);
expect(readFileSync(join(resolved, "schemas", "api.schema.json"), "utf8")).toBe("{}");
expect(fetcher).toHaveBeenCalledTimes(2);
});
it.each([
["7.8.9", "copilot-cli", "v7.8.9"],
["7.8.9-2", "copilot-cli", "v7.8.9-2"],
["7.8.9-unstable.r123.gabcdef0", "copilot-sdk", "runtime-7.8.9-unstable.r123.gabcdef0"],
["7.8.9-2.unstable.r123.gabcdef0", "copilot-sdk", "runtime-7.8.9-2.unstable.r123.gabcdef0"],
])(
"downloads, verifies, and caches %s for source packaging",
async (version, repository, tag) => {
const sourceRoot = mkdtempSync(join(tmpdir(), "copilot-release-source-"));
onTestFinished(() => rmSync(sourceRoot, { recursive: true, force: true }));
const packageRoot = join(sourceRoot, "package");
const platform = "linux-x64";
const prebuilds = join(packageRoot, "prebuilds", platform);
mkdirSync(prebuilds, { recursive: true });
writeFileSync(join(prebuilds, "copilot-runtime"), "wrapper");
writeFileSync(join(prebuilds, "runtime.node"), "runtime");
mkdirSync(join(packageRoot, "schemas"), { recursive: true });
writeFileSync(join(packageRoot, "schemas", "api.schema.json"), "{}");
const archivePath = join(sourceRoot, "runtime.tgz");
await createTar({ cwd: sourceRoot, file: archivePath, gzip: true }, ["package"]);
const archive = readFileSync(archivePath);
const assetName = getRuntimeReleaseAssetName(version, platform);
const checksum = createHash("sha256").update(archive).digest("hex");
vi.stubEnv("COPILOT_CLI_DOWNLOAD_BASE_URL", "https://ambient.example.invalid/releases");
onTestFinished(() => vi.unstubAllEnvs());
for (const mirror of [undefined, "https://mirror.example.invalid/releases///"]) {
const base =
mirror?.replace(/\/+$/, "") ??
`https://github.com/github/${repository}/releases/download`;
const releaseUrl = `${base}/${tag}`;
const fetcher = vi.fn(async (input: string | URL | Request) => {
const url = String(input);
if (url === `${releaseUrl}/SHA256SUMS.txt`)
return new Response(`${checksum} ${assetName}\n`);
if (url === `${releaseUrl}/${assetName}`) return new Response(archive);
return new Response("Unexpected release URL", { status: 404 });
});
const environment = { COPILOT_CLI_DOWNLOAD_BASE_URL: mirror };
const cacheRoot = join(sourceRoot, mirror ? "mirror-cache" : "cache");
await expect(
downloadVerifiedReleaseAsset(version, assetName, {
environment,
fetch: fetcher,
})
).resolves.toEqual(archive);
const options = {
cacheRoot,
fetch: fetcher,
platform,
environment,
};
const downloadedPackage = await ensureCopilotPackage(version, options);
expect(
readFileSync(join(downloadedPackage, "schemas", "api.schema.json"), "utf8")
).toBe("{}");
await expect(ensureCopilotPackage(version, options)).resolves.toBe(
downloadedPackage
);
expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([
`${releaseUrl}/SHA256SUMS.txt`,
`${releaseUrl}/${assetName}`,
`${releaseUrl}/${assetName}`,
]);
}
}
);
it("rejects a release package that does not match SHA256SUMS.txt", async () => {
const cacheRoot = mkdtempSync(join(tmpdir(), "copilot-release-mismatch-"));
const assetName = getRuntimeReleaseAssetName("1.2.3", "linux-x64");
const fetcher = vi.fn(async (input: string | URL | Request) =>
String(input).endsWith("/SHA256SUMS.txt")
? new Response(`${"0".repeat(64)} ${assetName}\n`)
: new Response("corrupt archive")
);
await expect(
ensureCopilotPackage("1.2.3", {
cacheRoot,
fetch: fetcher,
platform: "linux-x64",
})
).rejects.toThrow("Checksum mismatch");
expect(existsSync(join(cacheRoot, "1.2.3", "packages", "linux-x64"))).toBe(false);
});
it("times out and retries a stalled release download", async () => {
const cacheRoot = mkdtempSync(join(tmpdir(), "copilot-release-timeout-"));
const fetcher = vi.fn(
(_input: string | URL | Request, init?: RequestInit) =>
new Promise<Response>((_resolve, reject) => {
const signal = init?.signal;
if (!signal) {
reject(new Error("Expected a request timeout signal."));
return;
}
signal.addEventListener("abort", () => reject(signal.reason), { once: true });
})
);
await expect(
ensureCopilotPackage("1.2.3-timeout", {
cacheRoot,
fetch: fetcher,
fetchTimeoutMs: 10,
platform: "linux-x64",
})
).rejects.toThrow("Failed to download");
expect(fetcher).toHaveBeenCalledTimes(3);
});
});