fix(test): strip windows drive prefix from darwin hints

This commit is contained in:
Peter Steinberger
2026-03-07 21:46:34 +00:00
parent eb616b709f
commit 4dcd930923
2 changed files with 36 additions and 2 deletions

View File

@@ -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") {

View File

@@ -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",
]);
});
});