@@ -24,6 +24,9 @@ describe("scripts/perf/summarize-cpuprofile.mjs", () => {
|
24 | 24 | |
25 | 25 | it("prints help without treating it as a profile path", () => { |
26 | 26 | expect(shouldPrintHelp(["--help"])).toBe(true); |
| 27 | +expect(shouldPrintHelp(["--limit", "-h", "a.cpuprofile"])).toBe(false); |
| 28 | +expect(shouldPrintHelp(["--limit", "--", "--help"])).toBe(false); |
| 29 | +expect(shouldPrintHelp(["--limit=1e3", "--help"])).toBe(false); |
27 | 30 | expect(shouldPrintHelp(["--", "--help"])).toBe(false); |
28 | 31 | |
29 | 32 | const result = spawnSync( |
@@ -43,12 +46,27 @@ describe("scripts/perf/summarize-cpuprofile.mjs", () => {
|
43 | 46 | it("rejects malformed limit flags instead of falling back", () => { |
44 | 47 | for (const args of [ |
45 | 48 | ["--limit", "3frames", "a.cpuprofile"], |
| 49 | +["--limit", "-h", "a.cpuprofile"], |
| 50 | +["--limit", "--", "--help"], |
46 | 51 | ["--limit", "0", "a.cpuprofile"], |
47 | 52 | ["--limit=1e3", "a.cpuprofile"], |
48 | 53 | ["--limit"], |
49 | 54 | ]) { |
50 | 55 | expect(() => parseArgs(args)).toThrow("--limit must be a positive integer"); |
51 | 56 | } |
| 57 | + |
| 58 | +const result = spawnSync( |
| 59 | +process.execPath, |
| 60 | +["scripts/perf/summarize-cpuprofile.mjs", "--limit", "-h", "a.cpuprofile"], |
| 61 | +{ |
| 62 | +cwd: process.cwd(), |
| 63 | +encoding: "utf8", |
| 64 | +}, |
| 65 | +); |
| 66 | + |
| 67 | +expect(result.status).toBe(1); |
| 68 | +expect(result.stdout).toBe(""); |
| 69 | +expect(result.stderr.trim()).toBe("--limit must be a positive integer"); |
52 | 70 | }); |
53 | 71 | |
54 | 72 | it("rejects unknown options instead of treating them as profile paths", () => { |
|