From 674bd6fc93e74ada45fe0cedb4895565c08cea9c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 2 Jun 2026 04:41:55 +0200 Subject: [PATCH] fix(mac): isolate build run logs --- scripts/build-and-run-mac.sh | 5 +++-- test/scripts/build-and-run-mac.test.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/scripts/build-and-run-mac.test.ts diff --git a/scripts/build-and-run-mac.sh b/scripts/build-and-run-mac.sh index 3734606a83ea..ecf0ad670957 100755 --- a/scripts/build-and-run-mac.sh +++ b/scripts/build-and-run-mac.sh @@ -5,6 +5,7 @@ cd "$(dirname "$0")/../apps/macos" BUILD_PATH=".build-local" PRODUCT="OpenClaw" BIN="$BUILD_PATH/debug/$PRODUCT" +LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}" printf "\n▶️ Building $PRODUCT (debug, build path: $BUILD_PATH)\n" swift build -c debug --product "$PRODUCT" --build-path "$BUILD_PATH" @@ -13,6 +14,6 @@ printf "\n⏹ Stopping existing $PRODUCT...\n" killall -q "$PRODUCT" 2>/dev/null || true printf "\n🚀 Launching $BIN ...\n" -nohup "$BIN" >/tmp/openclaw.log 2>&1 & +nohup "$BIN" >"$LOG_PATH" 2>&1 & PID=$! -printf "Started $PRODUCT (PID $PID). Logs: /tmp/openclaw.log\n" +printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\n" diff --git a/test/scripts/build-and-run-mac.test.ts b/test/scripts/build-and-run-mac.test.ts new file mode 100644 index 000000000000..4ab2a7571e29 --- /dev/null +++ b/test/scripts/build-and-run-mac.test.ts @@ -0,0 +1,17 @@ +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; + +const scriptPath = "scripts/build-and-run-mac.sh"; + +describe("scripts/build-and-run-mac.sh", () => { + it("keeps launch logs isolated unless an explicit log path is provided", () => { + const script = readFileSync(scriptPath, "utf8"); + + expect(script).toContain( + 'LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"', + ); + expect(script).toContain('nohup "$BIN" >"$LOG_PATH" 2>&1 &'); + expect(script).toContain('printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\\n"'); + expect(script).not.toContain("/tmp/openclaw.log"); + }); +});