2025-12-24 22:16:06 +01:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension ProcessInfo {
|
|
|
|
|
var isPreview: Bool {
|
2026-01-07 20:13:24 +00:00
|
|
|
guard let raw = getenv("XCODE_RUNNING_FOR_PREVIEWS") else { return false }
|
|
|
|
|
return String(cString: raw) == "1"
|
2025-12-24 22:16:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-20 21:32:06 +01:00
|
|
|
var isNixMode: Bool {
|
2026-01-30 03:15:10 +01:00
|
|
|
if let raw = getenv("OPENCLAW_NIX_MODE"), String(cString: raw) == "1" { return true }
|
|
|
|
|
return UserDefaults.standard.bool(forKey: "openclaw.nixMode")
|
2025-12-20 21:32:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-24 22:16:06 +01:00
|
|
|
var isRunningTests: Bool {
|
|
|
|
|
// SwiftPM tests load one or more `.xctest` bundles. With Swift Testing, `Bundle.main` is not
|
|
|
|
|
// guaranteed to be the `.xctest` bundle, so check all loaded bundles.
|
|
|
|
|
if Bundle.allBundles.contains(where: { $0.bundleURL.pathExtension == "xctest" }) { return true }
|
|
|
|
|
if Bundle.main.bundleURL.pathExtension == "xctest" { return true }
|
|
|
|
|
|
|
|
|
|
// Backwards-compatible fallbacks for runners that still set XCTest env vars.
|
|
|
|
|
return self.environment["XCTestConfigurationFilePath"] != nil
|
|
|
|
|
|| self.environment["XCTestBundlePath"] != nil
|
|
|
|
|
|| self.environment["XCTestSessionIdentifier"] != nil
|
|
|
|
|
}
|
|
|
|
|
}
|