Files
ggbond268--mactools/Tests/Core/Plugins/PluginInvocationGuardTests.swift
wehub-resource-sync 1d1286fadb
Build / Build and test (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:18:38 +08:00

31 lines
899 B
Swift

import Foundation
import XCTest
@testable import MacTools
@MainActor
final class PluginInvocationGuardTests: XCTestCase {
func testRunCatchesObjectiveCException() {
let result = PluginInvocationGuard.run(operation: "test exception") {
raiseTestPluginException(reason: "boom")
}
switch result {
case .success:
XCTFail("Expected Objective-C exception to be caught")
case let .failure(.objectiveCException(name, reason)):
XCTAssertEqual(name, "TestPluginException")
XCTAssertEqual(reason, "boom")
case let .failure(failure):
XCTFail("Unexpected failure: \(failure.localizedDescription)")
}
}
}
func raiseTestPluginException(reason: String) {
NSException(
name: NSExceptionName("TestPluginException"),
reason: reason,
userInfo: nil
).raise()
}