PulseCanvas / app · pulsecanvas.ai / scripts / UpdaterSmoke.swift
| 1 | import AppKit |
| 2 | import Foundation |
| 3 | |
| 4 | @main struct UpdaterSmoke { |
| 5 | @MainActor static func main() async throws { |
| 6 | let app = NSApplication.shared |
| 7 | app.setActivationPolicy(.prohibited) |
| 8 | app.finishLaunching() |
| 9 | let updater = AppUpdater() |
| 10 | let expected = Bundle.main.object(forInfoDictionaryKey: "UpdaterExpectedVersion") as? String |
| 11 | let checksEnabled = Bundle.main.object(forInfoDictionaryKey: "SUEnableAutomaticChecks") as? Bool ?? false |
| 12 | for _ in 0..<500 { |
| 13 | if let expected, updater.availableVersion == expected { break } |
| 14 | try await Task.sleep(nanoseconds: 20_000_000) |
| 15 | } |
| 16 | precondition(updater.automaticChecks == checksEnabled) |
| 17 | precondition(updater.availableVersion == expected, |
| 18 | "Unexpected update availability: \(updater.availableVersion ?? "none")") |
| 19 | if expected != nil { precondition(updater.canCheck, "The available update must be actionable") } |
| 20 | print("PASS real Sparkle probe: \(expected ?? "no update"), automatic checks \(checksEnabled)") |
| 21 | } |
| 22 | } |