|
| 1 | +import { spawnSync } from "node:child_process"; |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | + |
| 4 | +function runProfileExtensionMemory(args: string[]) { |
| 5 | + return spawnSync(process.execPath, ["scripts/profile-extension-memory.mjs", ...args], { |
| 6 | + cwd: process.cwd(), |
| 7 | + encoding: "utf8", |
| 8 | + }); |
| 9 | +} |
| 10 | + |
| 11 | +describe("scripts/profile-extension-memory", () => { |
| 12 | + it("prints help without requiring built plugin artifacts", () => { |
| 13 | + const result = runProfileExtensionMemory(["--help"]); |
| 14 | + |
| 15 | + expect(result.status).toBe(0); |
| 16 | + expect(result.stderr).toBe(""); |
| 17 | + expect(result.stdout).toContain("Usage: node scripts/profile-extension-memory.mjs"); |
| 18 | + }); |
| 19 | + |
| 20 | + it("rejects loose numeric flags before scanning built plugin artifacts", () => { |
| 21 | + const cases = [ |
| 22 | + ["--concurrency", "2abc"], |
| 23 | + ["--timeout-ms", "1e3"], |
| 24 | + ["--combined-timeout-ms", "90000ms"], |
| 25 | + ["--top", "0x10"], |
| 26 | + ]; |
| 27 | + |
| 28 | + for (const [flag, value] of cases) { |
| 29 | + const result = runProfileExtensionMemory([flag, value]); |
| 30 | + |
| 31 | + expect(result.status).toBe(1); |
| 32 | + expect(result.stdout).toBe(""); |
| 33 | + expect(result.stderr).toContain(`[extension-memory] ${flag} must be a positive integer`); |
| 34 | + expect(result.stderr).not.toContain("dist/extensions"); |
| 35 | + expect(result.stderr).not.toContain("at "); |
| 36 | + } |
| 37 | + }); |
| 38 | +}); |
0 commit comments