Files
oh-my-pi/packages/utils/test/postmortem-quit.test.ts
T
can1357 f925f9f38a test(utils): cover quit without stdout drain
(cherry picked from commit 59a8002411726d8686c187a6d031a1f54577093b)
2026-07-29 23:08:32 +02:00

26 lines
785 B
TypeScript

import { describe, expect, it } from "bun:test";
import * as postmortem from "../src/postmortem";
const childFlag = "--quit-without-drain-child";
if (process.argv.includes(childFlag)) {
Object.defineProperty(process.stdout, "writableLength", { value: 1, configurable: true });
await postmortem.quit(23, { drainStdout: false });
}
describe("postmortem quit", () => {
it("exits without waiting for pending stdout when draining is disabled", async () => {
const child = Bun.spawn([process.execPath, import.meta.path, childFlag], {
stdout: "pipe",
stderr: "pipe",
});
const timeout = Bun.sleep(500).then(() => "timeout" as const);
try {
expect(await Promise.race([child.exited, timeout])).toBe(23);
} finally {
child.kill();
await child.exited;
}
});
});