Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions macos/Scripts/dev-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
# Usage: Scripts/dev-run.sh [--no-launch] [--log]
# --no-launch build & sign only, do not start the app
# --log after launching, tail -f ~/Library/Logs/LCTMac.log
# --log after launching, tail -F ~/Library/Logs/LCTMac.log

set -euo pipefail

Expand Down Expand Up @@ -162,7 +162,10 @@ if [ "$LAUNCH" -eq 1 ]; then
echo "dev-run.sh: launched $APP_BUNDLE"
if [ "$TAIL_LOG" -eq 1 ]; then
echo "dev-run.sh: tailing $LOG_FILE (Ctrl-C to stop)"
tail -f "$LOG_FILE"
# -F, not -f: the app replaces the log file (new inode) when it
# finishes launching, which is usually after tail has started, and
# `tail -f` would keep following the old, deleted file.
tail -F "$LOG_FILE"
fi
else
echo "dev-run.sh: build complete (--no-launch): $APP_BUNDLE"
Expand Down
16 changes: 16 additions & 0 deletions macos/Tests/LCTMacTests/DevRunTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ final class DevRunTests: XCTestCase {
XCTAssertFalse(log.contains("open "), "--no-launch must not open the app, got: \(log)")
}

func testDevRun_Log_FollowsLogFileByName() throws {
let stubs = try makeStubbedRun(securityOutput: nil)
try writeExecutable("tail", contents: """
#!/bin/bash
echo "tail $*" >> "$LCT_STUB_LOG"
""", in: stubs.workDir.appendingPathComponent("bin"))
let result = try run("dev-run.sh", arguments: ["--log"], stubs: stubs, identity: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF")

XCTAssertEqual(result.exitStatus, 0, "dev-run.sh failed: \(result.stderr)")
let log = stubLog(stubs)
XCTAssertTrue(
log.contains("tail -F ") && log.contains("Library/Logs/LCTMac.log"),
"the app replaces its log file on launch, so --log must follow it by name (tail -F), got: \(log)"
)
}

func testDevRun_RunningInstance_QuitsGracefullyWithoutPkill() throws {
let pgrep = """
#!/bin/bash
Expand Down
Loading