|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | + |
| 3 | +type PackageSmokeTimeouts = { |
| 4 | + packageSmokeTimeouts: (platform?: NodeJS.Platform) => { |
| 5 | + commandTimeoutMs: number; |
| 6 | + processTimeoutMs: number; |
| 7 | + }; |
| 8 | +}; |
| 9 | + |
| 10 | +const { packageSmokeTimeouts } = (await import( |
| 11 | + new URL("../scripts/package-smoke-timeouts.mjs", import.meta.url).href |
| 12 | +)) as PackageSmokeTimeouts; |
| 13 | + |
| 14 | +describe("npm package smoke timeouts", () => { |
| 15 | + test("preserves the existing timeout on Linux and macOS", () => { |
| 16 | + for (const platform of ["linux", "darwin"] as const) { |
| 17 | + expect(packageSmokeTimeouts(platform)).toEqual({ |
| 18 | + commandTimeoutMs: 120_000, |
| 19 | + processTimeoutMs: 150_000, |
| 20 | + }); |
| 21 | + } |
| 22 | + }); |
| 23 | + |
| 24 | + test("allows the Windows npm install to complete", () => { |
| 25 | + expect(packageSmokeTimeouts("win32")).toEqual({ |
| 26 | + commandTimeoutMs: 180_000, |
| 27 | + processTimeoutMs: 210_000, |
| 28 | + }); |
| 29 | + }); |
| 30 | + |
| 31 | + test("keeps the parent smoke timeout above the command timeout", () => { |
| 32 | + for (const platform of ["linux", "darwin", "win32"] as const) { |
| 33 | + const { commandTimeoutMs, processTimeoutMs } = |
| 34 | + packageSmokeTimeouts(platform); |
| 35 | + |
| 36 | + expect(processTimeoutMs).toBe(commandTimeoutMs + 30_000); |
| 37 | + } |
| 38 | + }); |
| 39 | + |
| 40 | + test("uses the active runtime platform by default", () => { |
| 41 | + expect(packageSmokeTimeouts()).toEqual( |
| 42 | + packageSmokeTimeouts(process.platform), |
| 43 | + ); |
| 44 | + }); |
| 45 | +}); |
0 commit comments