Files
openclaw/apps/macos/Tests/OpenClawIPCTests/LogLocatorTests.swift
Peter Steinberger 76154d9275 test(macos): deflake browser proxy gate tests via injectable browser control (#100517)
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.
2026-07-06 02:13:05 +01:00

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)
}
}