mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-16 22:51:37 +00:00
MacNodeRuntime's browser proxy gate read OPENCLAW_CONFIG_PATH-resolved config at invoke time, so parallel tests mutating process env (raw setenv outside TestIsolationLock in LogLocatorTests/WideAreaGatewayDiscoveryTests) could make the gate read the real host config. Inject the gate state in tests, cover the config flag parsing in OpenClawConfigFileTests, and route remaining raw setenv test users through TestIsolation.withEnvValues.
23 lines
865 B
Swift
23 lines
865 B
Swift
import Foundation
|
|
import Testing
|
|
@testable import OpenClaw
|
|
|
|
struct LogLocatorTests {
|
|
@Test func `launchd gateway log path ensures tmp dir exists`() async {
|
|
let fm = FileManager()
|
|
let baseDir = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
|
let logDir = baseDir.appendingPathComponent("openclaw-tests-\(UUID().uuidString)")
|
|
defer { try? fm.removeItem(at: logDir) }
|
|
|
|
// Env mutation must hold TestIsolationLock; raw setenv races parallel
|
|
// tests scanning environ (e.g. OPENCLAW_CONFIG_PATH readers).
|
|
await TestIsolation.withEnvValues(["OPENCLAW_LOG_DIR": logDir.path]) {
|
|
_ = LogLocator.launchdGatewayLogPath
|
|
}
|
|
|
|
var isDir: ObjCBool = false
|
|
#expect(fm.fileExists(atPath: logDir.path, isDirectory: &isDir))
|
|
#expect(isDir.boolValue == true)
|
|
}
|
|
}
|