Add CI environment detection to isRunningTests

Add checks for GITHUB_ACTIONS, CI, and XCTestBundlePath environment
variables to reliably detect test/CI environments where notification
APIs should be skipped.
This commit is contained in:
jack
2025-11-25 09:29:26 -10:00
parent 858e878959
commit d2edb651c1
+7 -3
View File
@@ -17,10 +17,14 @@ import AppKit
final class NotificationService {
static let shared = NotificationService()
/// Returns true if running in test environment (XCTest or Swift Testing)
/// Returns true if running in test environment (XCTest, Swift Testing, or CI)
private var isRunningTests: Bool {
NSClassFromString("XCTestCase") != nil ||
ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil
let env = ProcessInfo.processInfo.environment
return NSClassFromString("XCTestCase") != nil ||
env["XCTestConfigurationFilePath"] != nil ||
env["XCTestBundlePath"] != nil ||
env["GITHUB_ACTIONS"] != nil ||
env["CI"] != nil
}
private init() {}