MCPcopy Create free account
hub / github.com/backnotprop/plannotator / makeRuntime

Function makeRuntime

packages/shared/semantic-diff.test.ts:21–57  ·  view source on GitHub ↗
(options: {
  cwd?: string;
  env?: Record<string, string | undefined>;
  files?: string[];
  commands?: Record<string, MockCommand>;
  pathDelimiter?: string;
  platform?: NodeJS.Platform;
} = {})

Source from the content-addressed store, hash-verified

19}
20
21function makeRuntime(options: {
22 cwd?: string;
23 env?: Record<string, string | undefined>;
24 files?: string[];
25 commands?: Record<string, MockCommand>;
26 pathDelimiter?: string;
27 platform?: NodeJS.Platform;
28} = {}): SemanticDiffRuntime & { calls: Array<{ command: string; args: string[]; input?: string }> } {
29 const calls: Array<{ command: string; args: string[]; input?: string }> = [];
30 const files = new Set(options.files ?? []);
31 const commands = options.commands ?? {};
32
33 return {
34 calls,
35 env: options.env ?? {},
36 cwd: options.cwd ?? "/repo",
37 dataDir: "/home/user/.plannotator",
38 pathDelimiter: options.pathDelimiter ?? ":",
39 platform: options.platform ?? "linux",
40 fileExists(path) {
41 return files.has(path);
42 },
43 async runCommand(command, args, runOptions) {
44 calls.push({ command, args, input: runOptions?.input });
45 const mock = commands[command];
46 if (!mock) return { stdout: "", stderr: "not found", exitCode: 1, error: "not found" };
47 if (args.includes("--version")) {
48 return { stdout: mock.version ?? "", stderr: "", exitCode: mock.version ? 0 : 1 };
49 }
50 return {
51 stdout: mock.diff ?? "",
52 stderr: mock.stderr ?? "",
53 exitCode: mock.exitCode ?? 0,
54 };
55 },
56 };
57}
58
59describe("semantic diff runner", () => {
60 test("parses real sem version output and rejects other sem commands", () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected