Skip to content

Commit e801a0d

Browse files
committed
Always invoke Issue.record and XCTFail in tests
That way, `Issue.record` properly funnels to Swift Testing when called from an unstructured place, like `isolated deinit`s. It also doesn't hurt to invoke `XCTFail` from `Swift Testing`, or vice versa. Fixes #170.
1 parent b2ed9ea commit e801a0d

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

Sources/IssueReporting/ReportIssue.swift

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public func reportIssue(
4040
IssueContext.current?.line ?? line,
4141
IssueContext.current?.column ?? column
4242
)
43-
guard let context = TestContext.current else {
43+
guard TestContext.current != nil else {
4444
guard !isTesting else { return }
4545
if let observer = FailureObserver.current {
4646
observer.withLock { $0 += 1 }
@@ -66,24 +66,18 @@ public func reportIssue(
6666
}
6767
return
6868
}
69-
70-
switch context {
71-
case .swiftTesting:
72-
_recordIssue(
73-
message: message(),
74-
fileID: "\(fileID)",
75-
filePath: "\(filePath)",
76-
line: Int(line),
77-
column: Int(column)
78-
)
79-
case .xcTest:
80-
_XCTFail(
81-
message().withAppHostWarningIfNeeded() ?? "",
82-
file: filePath,
83-
line: line
84-
)
85-
@unknown default: break
86-
}
69+
_recordIssue(
70+
message: message(),
71+
fileID: "\(fileID)",
72+
filePath: "\(filePath)",
73+
line: Int(line),
74+
column: Int(column)
75+
)
76+
_XCTFail(
77+
message().withAppHostWarningIfNeeded() ?? "",
78+
file: filePath,
79+
line: line
80+
)
8781
}
8882

8983
/// Report a caught error.

0 commit comments

Comments
 (0)