Skip to content

Commit 5a83ae0

Browse files
committed
Suppress ExpectationFailedError in withKnownIssue
1 parent b33a9d6 commit 5a83ae0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/Testing/Issues/KnownIssue.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ struct KnownIssueScope: Sendable {
7777
/// - sourceLocation: The source location to which the issue should be
7878
/// attributed.
7979
private func _matchError(_ error: any Error, in scope: KnownIssueScope, comment: Comment?, sourceLocation: SourceLocation) throws {
80+
if error is ExpectationFailedError {
81+
// An `ExpectationFailedError` instance was thrown through the call to
82+
// `withKnownIssue {}` from a call to `#require()`. The original issue (of
83+
// kind `expectationFailed`) will have already been handled by this point,
84+
// so we don't want to try to handle it again.
85+
throw error
86+
}
87+
8088
let sourceContext = SourceContext(backtrace: Backtrace(forFirstThrowOf: error), sourceLocation: sourceLocation)
8189
var issue = Issue(kind: .errorCaught(error), comments: [], sourceContext: sourceContext)
8290
if let context = scope.matcher(issue) {

0 commit comments

Comments
 (0)