The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { assert, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { |
| 4 | parseProcStatParentPid, |
| 5 | parseProcStatusBytes, |
| 6 | processTreePids, |
| 7 | } from "./dev-memory-limit.ts"; |
| 8 | |
| 9 | it("counts RAM and swap for the dev runner's descendants only", () => { |
| 10 | assert.strictEqual(parseProcStatParentPid("812 (node (vite) 2) S 77 812 812 0 -1"), 77); |
| 11 | assert.strictEqual( |
| 12 | parseProcStatusBytes("Name:\tnode\nVmRSS:\t 2048 kB\nVmSwap:\t 1024 kB\nThreads:\t9\n"), |
| 13 | 3 * 1024 * 1024, |
| 14 | ); |
| 15 | // Listed before its parent, as /proc may order them. |
| 16 | const processes = [ |
| 17 | { pid: 30, ppid: 20 }, |
| 18 | { pid: 20, ppid: 10 }, |
| 19 | { pid: 11, ppid: 1 }, |
| 20 | { pid: 10, ppid: 1 }, |
| 21 | ]; |
| 22 | assert.deepStrictEqual([...processTreePids(10, processes)].sort(), [10, 20, 30]); |
| 23 | }); |