Skip to content

Commit 38a04c0

Browse files
Expose issue severity and isFailure as API
1 parent 55f82ed commit 38a04c0

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

Sources/Testing/Issues/Issue+Recording.swift

Lines changed: 1 addition & 43 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,7 +71,6 @@ 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,
9676
severity: Severity,
@@ -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,7 +101,6 @@ 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,

Sources/Testing/Issues/Issue.swift

Lines changed: 5 additions & 2 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,8 +100,12 @@ public struct Issue: Sendable {
101100
}
102101

103102
/// The severity of this issue.
104-
@_spi(Experimental)
105103
public var severity: Severity
104+
105+
/// If the issues is a failing issue.
106+
public var isFailure: Bool {
107+
severity == .error
108+
}
106109

107110
/// Any comments provided by the developer and associated with this issue.
108111
///

0 commit comments

Comments
 (0)