From 4dcd93092334789ed3c32c539ff81730275ff5a7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 7 Mar 2026 21:46:34 +0000 Subject: [PATCH] fix(test): strip windows drive prefix from darwin hints --- src/daemon/runtime-hints.ts | 8 +++-- .../runtime-hints.windows-paths.test.ts | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/daemon/runtime-hints.windows-paths.test.ts diff --git a/src/daemon/runtime-hints.ts b/src/daemon/runtime-hints.ts index 0d8fbfceced..09d106af7ea 100644 --- a/src/daemon/runtime-hints.ts +++ b/src/daemon/runtime-hints.ts @@ -1,6 +1,10 @@ import { resolveGatewayLogPaths } from "./launchd.js"; import { toPosixPath } from "./output.js"; +function toDarwinDisplayPath(value: string): string { + return toPosixPath(value).replace(/^[A-Za-z]:/, ""); +} + export function buildPlatformRuntimeLogHints(params: { platform?: NodeJS.Platform; env?: NodeJS.ProcessEnv; @@ -12,8 +16,8 @@ export function buildPlatformRuntimeLogHints(params: { if (platform === "darwin") { const logs = resolveGatewayLogPaths(env); return [ - `Launchd stdout (if installed): ${toPosixPath(logs.stdoutPath)}`, - `Launchd stderr (if installed): ${toPosixPath(logs.stderrPath)}`, + `Launchd stdout (if installed): ${toDarwinDisplayPath(logs.stdoutPath)}`, + `Launchd stderr (if installed): ${toDarwinDisplayPath(logs.stderrPath)}`, ]; } if (platform === "linux") { diff --git a/src/daemon/runtime-hints.windows-paths.test.ts b/src/daemon/runtime-hints.windows-paths.test.ts new file mode 100644 index 00000000000..450f517ec11 --- /dev/null +++ b/src/daemon/runtime-hints.windows-paths.test.ts @@ -0,0 +1,30 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; + +afterEach(() => { + vi.resetModules(); + vi.doUnmock("./launchd.js"); +}); + +describe("buildPlatformRuntimeLogHints", () => { + it("strips windows drive prefixes from darwin display paths", async () => { + vi.doMock("./launchd.js", () => ({ + resolveGatewayLogPaths: () => ({ + stdoutPath: "C:\\tmp\\openclaw-state\\logs\\gateway.log", + stderrPath: "C:\\tmp\\openclaw-state\\logs\\gateway.err.log", + }), + })); + + const { buildPlatformRuntimeLogHints } = await import("./runtime-hints.js"); + + expect( + buildPlatformRuntimeLogHints({ + platform: "darwin", + systemdServiceName: "openclaw-gateway", + windowsTaskName: "OpenClaw Gateway", + }), + ).toEqual([ + "Launchd stdout (if installed): /tmp/openclaw-state/logs/gateway.log", + "Launchd stderr (if installed): /tmp/openclaw-state/logs/gateway.err.log", + ]); + }); +});