mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
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>
This commit is contained in:
co-authored by
miguel.sierra
parent
ef48485b91
commit
08d48ab753
@@ -0,0 +1,33 @@
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user