diff options
Diffstat (limited to 'test/util/daemon-socket-test.ts')
| -rw-r--r-- | test/util/daemon-socket-test.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/util/daemon-socket-test.ts b/test/util/daemon-socket-test.ts index eee0500..80a03e4 100644 --- a/test/util/daemon-socket-test.ts +++ b/test/util/daemon-socket-test.ts @@ -1,10 +1,11 @@ import { test, describe } from "node:test"; import assert from "node:assert/strict"; import { fileURLToPath } from "node:url"; +import { existsSync } from "node:fs"; import { Type } from "typebox"; import type { ExtensionAPI, ToolDefinition } from "@mariozechner/pi-coding-agent"; import type { TSchema } from "typebox"; -import { daemonSocketMayExist } from "../../src/daemon/spawn"; +import { daemonSocketMayExist, daemonSpawnCommand } from "../../src/daemon/spawn"; import { type AnyBrowserToolDefinition, registerBrowserTool } from "../../src/util/tool"; import type { BrowserClient } from "../../src/client"; import { ok } from "../../src/util/result"; @@ -32,6 +33,28 @@ describe("daemon socket presence check", () => { }); }); +describe("daemon spawn command", () => { + test("the daemon runs on this process's node, not a shell", () => { + const spec = daemonSpawnCommand(); + assert.notEqual(spec, null); + assert.equal(spec?.command, process.execPath); + }); + + test("the resolved tsx CLI is a real file on disk", () => { + const cli = daemonSpawnCommand()?.args[0]; + assert.equal(typeof cli, "string"); + // A hoisted install puts tsx beside the package, so a `<pkg>/node_modules/.bin` guess would miss it. + assert.equal(existsSync(String(cli)), true, `tsx CLI not found at ${String(cli)}`); + assert.match(String(cli), /cli\.mjs$/); + }); + + test("the daemon entrypoint is passed to tsx", () => { + const script = daemonSpawnCommand()?.args[1]; + assert.match(String(script), /[\\/]daemon[\\/]index\.ts$/); + assert.equal(existsSync(String(script)), true); + }); +}); + type GateProbe = { readonly ran: ReadonlyArray<string>; readonly text: string }; const runGate = async (ensureAlive: boolean | undefined): Promise<GateProbe> => { |
