Skip to content

Cursor plugin specification and official plugins

TypeScript

test(pstack): wait for the reap in the statechart SIGKILL view test (#981)

lauren519d36aa9895
diff --git a/harness/pstack/claude-code/skills/statechart/scripts/test/cli.test.ts b/harness/pstack/claude-code/skills/statechart/scripts/test/cli.test.ts
index e14a44c1..97b71c30 100644
--- a/harness/pstack/claude-code/skills/statechart/scripts/test/cli.test.ts
+++ b/harness/pstack/claude-code/skills/statechart/scripts/test/cli.test.ts
@@ -275,13 +275,21 @@ async function signalWhile<T extends { dir: string; reached: (parent: string) =>
async function assertGone(pid: number) {
for (let i = 0; ; i++) {
+ let code: string | undefined;
try {
process.kill(pid, 0);
} catch (error) {
- assert.equal((error as NodeJS.ErrnoException).code, "ESRCH");
- return;
+ code = (error as NodeJS.ErrnoException).code;
+ // macOS gives EPERM for a process group of only zombies, until they are reaped.
+ if (code !== "EPERM") {
+ assert.equal(code, "ESRCH");
+ return;
+ }
}
- assert.ok(i < 250, `Process ${pid} is still running.`);
+ assert.ok(
+ i < 250,
+ `Process ${pid} ${code ? "exited, but it was not reaped" : "is still running"}.`,
+ );
await sleep(20);
}
}
diff --git a/pstack/skills/statechart/scripts/test/cli.test.ts b/pstack/skills/statechart/scripts/test/cli.test.ts
index e14a44c1..97b71c30 100644
--- a/pstack/skills/statechart/scripts/test/cli.test.ts
+++ b/pstack/skills/statechart/scripts/test/cli.test.ts
@@ -275,13 +275,21 @@ async function signalWhile<T extends { dir: string; reached: (parent: string) =>
async function assertGone(pid: number) {
for (let i = 0; ; i++) {
+ let code: string | undefined;
try {
process.kill(pid, 0);
} catch (error) {
- assert.equal((error as NodeJS.ErrnoException).code, "ESRCH");
- return;
+ code = (error as NodeJS.ErrnoException).code;
+ // macOS gives EPERM for a process group of only zombies, until they are reaped.
+ if (code !== "EPERM") {
+ assert.equal(code, "ESRCH");
+ return;
+ }
}
- assert.ok(i < 250, `Process ${pid} is still running.`);
+ assert.ok(
+ i < 250,
+ `Process ${pid} ${code ? "exited, but it was not reaped" : "is still running"}.`,
+ );
await sleep(20);
}
}