Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import AppKitimport Foundationimport Testing
@MainActorenum E2EApplicationLaunch { static func open( at url: URL, arguments: [String] = [], environment: [String: String], launch: @MainActor (URL, NSWorkspace.OpenConfiguration) async throws -> NSRunningApplication = { try await NSWorkspace.shared.openApplication(at: $0, configuration: $1) } ) async throws -> NSRunningApplication { let configuration = NSWorkspace.OpenConfiguration() configuration.arguments = arguments configuration.environment = environment // Launch Services gives the bundle its own TCC responsibility rather than inheriting the runner's. configuration.createsNewApplicationInstance = true configuration.activates = false configuration.addsToRecentItems = false return try await launch(url, configuration) }
static func stop(_ application: NSRunningApplication) async { guard !application.isTerminated else { return } let pid = application.processIdentifier guard application.terminate() else { Issue.record("Parcel application \(pid) refused termination") await forceStop(application) return } do { try await waitUntil("application \(pid) termination", timeout: .seconds(15)) { application.isTerminated } } catch { Issue.record(error) await forceStop(application) } }
private static func forceStop(_ application: NSRunningApplication) async { guard !application.isTerminated else { return } guard application.forceTerminate() else { Issue.record("Could not force termination of application \(application.processIdentifier)") return } do { try await waitUntil("forced application termination", timeout: .seconds(3)) { application.isTerminated } } catch { Issue.record(error) } }}