Skip to content

Commit 7616fc7

Browse files
Expose issue severity and isFailure as API
1 parent 64789e2 commit 7616fc7

File tree

2 files changed

+3
-48
lines changed

2 files changed

+3
-48
lines changed

Sources/Testing/Issues/Issue+Recording.swift

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,6 @@ extension Issue {
5858
return self
5959
}
6060

61-
/// Record an issue when a running test fails unexpectedly.
62-
///
63-
/// - Parameters:
64-
/// - comment: A comment describing the expectation.
65-
/// - sourceLocation: The source location to which the issue should be
66-
/// attributed.
67-
///
68-
/// - Returns: The issue that was recorded.
69-
///
70-
/// Use this function if, while running a test, an issue occurs that cannot be
71-
/// represented as an expectation (using the ``expect(_:_:sourceLocation:)``
72-
/// or ``require(_:_:sourceLocation:)-5l63q`` macros.)
73-
@discardableResult public static func record(
74-
_ comment: Comment? = nil,
75-
sourceLocation: SourceLocation = #_sourceLocation
76-
) -> Self {
77-
record(comment, severity: .error, sourceLocation: sourceLocation)
78-
}
79-
8061
/// Record an issue when a running test fails unexpectedly.
8162
///
8263
/// - Parameters:
@@ -90,10 +71,9 @@ extension Issue {
9071
/// Use this function if, while running a test, an issue occurs that cannot be
9172
/// represented as an expectation (using the ``expect(_:_:sourceLocation:)``
9273
/// or ``require(_:_:sourceLocation:)-5l63q`` macros.)
93-
@_spi(Experimental)
9474
@discardableResult public static func record(
9575
_ comment: Comment? = nil,
96-
severity: Severity,
76+
severity: Severity = .error,
9777
sourceLocation: SourceLocation = #_sourceLocation
9878
) -> Self {
9979
let sourceContext = SourceContext(backtrace: .current(), sourceLocation: sourceLocation)
@@ -105,28 +85,7 @@ extension Issue {
10585
// MARK: - Recording issues for errors
10686

10787
extension Issue {
108-
/// Record a new issue when a running test unexpectedly catches an error.
109-
///
110-
/// - Parameters:
111-
/// - error: The error that caused the issue.
112-
/// - comment: A comment describing the expectation.
113-
/// - sourceLocation: The source location to which the issue should be
114-
/// attributed.
115-
///
116-
/// - Returns: The issue that was recorded.
117-
///
118-
/// This function can be used if an unexpected error is caught while running a
119-
/// test and it should be treated as a test failure. If an error is thrown
120-
/// from a test function, it is automatically recorded as an issue and this
121-
/// function does not need to be used.
122-
@discardableResult public static func record(
123-
_ error: any Error,
124-
_ comment: Comment? = nil,
125-
sourceLocation: SourceLocation = #_sourceLocation
126-
) -> Self {
127-
record(error, comment, severity: .error, sourceLocation: sourceLocation)
128-
}
129-
88+
13089
/// Record a new issue when a running test unexpectedly catches an error.
13190
///
13291
/// - Parameters:
@@ -142,11 +101,10 @@ extension Issue {
142101
/// test and it should be treated as a test failure. If an error is thrown
143102
/// from a test function, it is automatically recorded as an issue and this
144103
/// function does not need to be used.
145-
@_spi(Experimental)
146104
@discardableResult public static func record(
147105
_ error: any Error,
148106
_ comment: Comment? = nil,
149-
severity: Severity,
107+
severity: Severity = .error,
150108
sourceLocation: SourceLocation = #_sourceLocation
151109
) -> Self {
152110
let backtrace = Backtrace(forFirstThrowOf: error) ?? Backtrace.current()

Sources/Testing/Issues/Issue.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public struct Issue: Sendable {
8484
///
8585
/// - ``warning``
8686
/// - ``error``
87-
@_spi(Experimental)
8887
public enum Severity: Sendable {
8988
/// The severity level for an issue which should be noted but is not
9089
/// necessarily an error.
@@ -101,7 +100,6 @@ public struct Issue: Sendable {
101100
}
102101

103102
/// The severity of this issue.
104-
@_spi(Experimental)
105103
public var severity: Severity
106104

107105
/// Whether or not this issue should cause the test it's associated with to be
@@ -114,7 +112,6 @@ public struct Issue: Sendable {
114112
///
115113
/// Use this property to determine if an issue should be considered a failure, instead of
116114
/// directly comparing the value of the ``severity`` property.
117-
@_spi(Experimental)
118115
public var isFailure: Bool {
119116
return !self.isKnown && self.severity >= .error
120117
}

0 commit comments

Comments
 (0)