MCPcopy Create free account
hub / github.com/cli/cli / observedProcess

Function observedProcess

evals/src/harness.test.ts:31–53  ·  view source on GitHub ↗
(t: TestContext, source: string)

Source from the content-addressed store, hash-verified

29}
30
31async function observedProcess(t: TestContext, source: string) {
32 const root = await temporary(t);
33 const binary = join(root, "real");
34 const wrapper = join(root, "gh");
35 await writeFile(binary, `#!${process.execPath}\n${source}\n`, { mode: 0o700 });
36 const calls: Call[] = [];
37 const observer = new CommandObserver(calls, () => {});
38 await observer.listen(join(root, ".sock"));
39 await writeGhWrapper(wrapper, binary, join(root, ".sock"));
40 const child = spawn(wrapper, ["event", "listen"], {
41 env: isolatedEnvironment(root, dirname(process.execPath) + ":/usr/bin:/bin", "unused"),
42 });
43 const completed = new Promise<number | null>((resolve, reject) => {
44 child.on("error", reject);
45 child.on("close", resolve);
46 });
47 t.after(async () => {
48 if (child.exitCode === null && child.signalCode === null) child.kill("SIGTERM");
49 await completed;
50 await observer.close();
51 });
52 return { calls, observer, child, completed };
53}
54
55interface Expected {
56 method: string;

Callers 1

harness.test.tsFile · 0.85

Calls 6

listenMethod · 0.95
closeMethod · 0.95
temporaryFunction · 0.85
writeGhWrapperFunction · 0.85
isolatedEnvironmentFunction · 0.85
writeFileFunction · 0.50

Tested by

no test coverage detected