2026-01-15 06:13:20 +00:00
|
|
|
import Darwin
|
2026-01-14 16:06:26 +00:00
|
|
|
import Foundation
|
|
|
|
|
import Testing
|
2026-01-30 03:15:10 +01:00
|
|
|
@testable import OpenClaw
|
2026-01-14 16:06:26 +00:00
|
|
|
|
|
|
|
|
@Suite struct LogLocatorTests {
|
|
|
|
|
@Test func launchdGatewayLogPathEnsuresTmpDirExists() throws {
|
2026-01-18 20:00:26 +01:00
|
|
|
let fm = FileManager()
|
2026-01-15 06:13:20 +00:00
|
|
|
let baseDir = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
2026-01-30 03:15:10 +01:00
|
|
|
let logDir = baseDir.appendingPathComponent("openclaw-tests-\(UUID().uuidString)")
|
2026-01-14 16:06:26 +00:00
|
|
|
|
2026-01-30 03:15:10 +01:00
|
|
|
setenv("OPENCLAW_LOG_DIR", logDir.path, 1)
|
2026-01-15 06:13:20 +00:00
|
|
|
defer {
|
2026-01-30 03:15:10 +01:00
|
|
|
unsetenv("OPENCLAW_LOG_DIR")
|
2026-01-15 06:13:20 +00:00
|
|
|
try? fm.removeItem(at: logDir)
|
2026-01-14 16:06:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ = LogLocator.launchdGatewayLogPath
|
|
|
|
|
|
|
|
|
|
var isDir: ObjCBool = false
|
2026-01-15 06:13:20 +00:00
|
|
|
#expect(fm.fileExists(atPath: logDir.path, isDirectory: &isDir))
|
2026-01-14 16:06:26 +00:00
|
|
|
#expect(isDir.boolValue == true)
|
|
|
|
|
}
|
|
|
|
|
}
|