Skip to content

Instantly share code, notes, and snippets.

@paulz
Last active March 31, 2020 08:25
Show Gist options
  • Select an option

  • Save paulz/e2068a3a635c1adf2050e2eb5c9b0a06 to your computer and use it in GitHub Desktop.

Select an option

Save paulz/e2068a3a635c1adf2050e2eb5c9b0a06 to your computer and use it in GitHub Desktop.
Expect Exception without breaking in debugger
objc_exception_throw:
console command:
script lldb.process.Continue() if (lldb.frame.GetThread().GetName() == "skip-objc_exception_throw") else None
it("should raise URL is nil") {
let selector = "-[NSFileManager enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:]"
let reason = "*** \(selector): URL is nil"
expectException(named: "NSInvalidArgumentException", reason: reason) {
subject.importFromURL()
}
}
import Nimble
func expectException(timeout: TimeInterval = AsyncDefaults.Timeout,
named: String? = nil,
reason: String? = nil,
file: FileString = #file,
line: UInt = #line,
block: @escaping () -> Void) {
waitUntil(timeout: timeout, file: file, line: line) { done in
let thread = Thread {
expect(file, line: line) {
block()
}.to(raiseException(named: named, reason: reason))
done()
}
thread.name = "skip-objc_exception_throw"
thread.start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment