Skip to content

Remove experimental spi from issue severity #1247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Sources/Testing/Issues/Issue+Recording.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension Issue {
return self
}

/// Record an issue when a running test fails unexpectedly.
/// Records an issue that a test encounters while it's running.
///
/// - Parameters:
/// - comment: A comment describing the expectation.
Expand All @@ -62,18 +62,23 @@ extension Issue {
/// Use this function if, while running a test, an issue occurs that cannot be
/// represented as an expectation (using the ``expect(_:_:sourceLocation:)``
/// or ``require(_:_:sourceLocation:)-5l63q`` macros.)
@_disfavoredOverload
@_documentation(visibility: private)
@available(*, deprecated, message: "Use record(_:severity:sourceLocation:) instead.")
@discardableResult public static func record(
_ comment: Comment? = nil,
sourceLocation: SourceLocation = #_sourceLocation
) -> Self {
record(comment, severity: .error, sourceLocation: sourceLocation)
}

/// Record an issue when a running test fails unexpectedly.
/// Records an issue that a test encounters while it's running.
///
/// - Parameters:
/// - comment: A comment describing the expectation.
/// - severity: The severity of the issue.
/// - severity: The severity level of the issue. The testing library marks the
/// test as failed if the severity is greater than ``Issue/Severity/warning``.
/// The default is ``Issue/Severity/error``.
/// - sourceLocation: The source location to which the issue should be
/// attributed.
///
Expand All @@ -82,10 +87,13 @@ extension Issue {
/// Use this function if, while running a test, an issue occurs that cannot be
/// represented as an expectation (using the ``expect(_:_:sourceLocation:)``
/// or ``require(_:_:sourceLocation:)-5l63q`` macros.)
@_spi(Experimental)
///
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
@discardableResult public static func record(
_ comment: Comment? = nil,
severity: Severity,
severity: Severity = .error,
sourceLocation: SourceLocation = #_sourceLocation
) -> Self {
let sourceContext = SourceContext(backtrace: .current(), sourceLocation: sourceLocation)
Expand Down
20 changes: 16 additions & 4 deletions Sources/Testing/Issues/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public struct Issue: Sendable {
///
/// - ``warning``
/// - ``error``
@_spi(Experimental)
///
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
public enum Severity: Sendable {
/// The severity level for an issue which should be noted but is not
/// necessarily an error.
Expand All @@ -101,7 +104,10 @@ public struct Issue: Sendable {
}

/// The severity of this issue.
@_spi(Experimental)
///
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
public var severity: Severity

/// Whether or not this issue should cause the test it's associated with to be
Expand All @@ -114,7 +120,10 @@ public struct Issue: Sendable {
///
/// Use this property to determine if an issue should be considered a failure, instead of
/// directly comparing the value of the ``severity`` property.
@_spi(Experimental)
///
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
public var isFailure: Bool {
return !self.isKnown && self.severity >= .error
}
Expand Down Expand Up @@ -324,7 +333,10 @@ extension Issue {
public var kind: Kind.Snapshot

/// The severity of this issue.
@_spi(Experimental)
///
/// @Metadata {
/// @Available(Swift, introduced: 6.3)
/// }
public var severity: Severity

/// Any comments provided by the developer and associated with this issue.
Expand Down
8 changes: 1 addition & 7 deletions Sources/Testing/Running/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ public struct Configuration: Sendable {
/// Whether or not events of the kind ``Event/Kind-swift.enum/issueRecorded(_:)``
/// containing issues with warning (or lower) severity should be delivered
/// to the event handler of the configuration these options are applied to.
///
/// By default, events matching this criteria are not delivered to event
/// handlers since this is an experimental feature.
///
/// - Warning: Warning issues are not yet an approved feature.
@_spi(Experimental)
public var isWarningIssueRecordedEventEnabled: Bool = false
public var isWarningIssueRecordedEventEnabled: Bool = true

/// Whether or not events of the kind
/// ``Event/Kind-swift.enum/expectationChecked(_:)`` should be delivered to
Expand Down