Files
hyperframes/packages/cli/src/utils/processTree.test.ts
T
heygengenesis[bot]andmiguel.sierra 08d48ab753 fix(cli): guard process snapshot capture (#3974)
Co-authored-by: heygengenesis[bot] <262951085+heygengenesis[bot]@users.noreply.github.com>
Co-authored-by: miguel.sierra <229591595+miguel-heygen@users.noreply.github.com>
2026-09-16 06:33:29 +00:00

34 lines
1.1 KiB
TypeScript

import { EventEmitter } from "node:events";
import { describe, expect, it, vi } from "vitest";
import {
terminateWindowsProcessTree,
windowsProcessTreeKillArgs,
type SpawnProcess,
} from "./processTree.js";
describe("Windows process-tree termination", () => {
it("runs taskkill recursively and forcefully through the platform seam", async () => {
const killer = new EventEmitter();
const spawnProcess = vi.fn<SpawnProcess>(() => killer);
const termination = terminateWindowsProcessTree(4321, spawnProcess);
killer.emit("close", 0);
await termination;
expect(spawnProcess).toHaveBeenCalledWith("taskkill", windowsProcessTreeKillArgs(4321), {
stdio: "ignore",
windowsHide: true,
});
});
it("surfaces taskkill failure so cancellable subprocesses can fall back", async () => {
const killer = new EventEmitter();
const spawnProcess = vi.fn<SpawnProcess>(() => killer);
const termination = terminateWindowsProcessTree(55, spawnProcess);
killer.emit("close", 1);
await expect(termination).rejects.toThrow("taskkill exited with status 1");
});
});