MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / processThatExitsOnKill

Function processThatExitsOnKill

packages/agent-core/test/tools/grep.test.ts:101–128  ·  view source on GitHub ↗
(stdout: string, stderr = '', exitCode = 143)

Source from the content-addressed store, hash-verified

99}
100
101function processThatExitsOnKill(stdout: string, stderr = '', exitCode = 143): KaosProcess {
102 let currentExitCode: number | null = null;
103 let resolveWait: (code: number) => void;
104 const waitPromise = new Promise<number>((resolve) => {
105 resolveWait = resolve;
106 });
107 const stdoutStream = Readable.from(stdout === '' ? [] : [stdout]);
108 const stderrStream = Readable.from(stderr === '' ? [] : [stderr]);
109
110 return {
111 stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable,
112 stdout: stdoutStream,
113 stderr: stderrStream,
114 pid: 123,
115 get exitCode() {
116 return currentExitCode;
117 },
118 wait: vi.fn(() => waitPromise),
119 kill: vi.fn(async () => {
120 currentExitCode = exitCode;
121 resolveWait(exitCode);
122 }),
123 dispose: vi.fn(async () => {
124 stdoutStream.destroy();
125 stderrStream.destroy();
126 }),
127 };
128}
129
130function context(args: GrepInput, abortSignal = signal) {
131 return { turnId: '0', toolCallId: 'call_grep', args, signal: abortSignal };

Callers 1

grep.test.tsFile · 0.85

Calls 2

destroyMethod · 0.80
resolveWaitFunction · 0.70

Tested by

no test coverage detected