Skip to content
Closed
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
8 changes: 6 additions & 2 deletions Sources/Testing/Issues/Issue+Recording.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extension Issue {
///
/// - Parameters:
/// - comment: A comment describing the expectation.
/// - kind: The kind of issue.
/// - sourceLocation: The source location to which the issue should be
/// attributed.
///
Expand All @@ -72,15 +73,17 @@ extension Issue {
/// or ``require(_:_:sourceLocation:)-5l63q`` macros.)
@discardableResult public static func record(
_ comment: Comment? = nil,
kind: Kind = .unconditional,
sourceLocation: SourceLocation = #_sourceLocation
) -> Self {
record(comment, severity: .error, sourceLocation: sourceLocation)
record(comment, kind: kind, severity: .error, sourceLocation: sourceLocation)
}

/// Record an issue when a running test fails unexpectedly.
///
/// - Parameters:
/// - comment: A comment describing the expectation.
/// - kind: The kind of issue.
/// - severity: The severity of the issue.
/// - sourceLocation: The source location to which the issue should be
/// attributed.
Expand All @@ -93,11 +96,12 @@ extension Issue {
@_spi(Experimental)
@discardableResult public static func record(
_ comment: Comment? = nil,
kind: Kind = .unconditional,
severity: Severity,
sourceLocation: SourceLocation = #_sourceLocation
) -> Self {
let sourceContext = SourceContext(backtrace: .current(), sourceLocation: sourceLocation)
let issue = Issue(kind: .unconditional, severity: severity, comments: Array(comment), sourceContext: sourceContext)
let issue = Issue(kind: kind, severity: severity, comments: Array(comment), sourceContext: sourceContext)
return issue.record()
}
}
Expand Down
17 changes: 17 additions & 0 deletions Sources/Testing/Issues/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public struct Issue: Sendable {
/// An issue due to a failure in the underlying system, not due to a failure
/// within the tests being run.
case system

/// An issue which occurred during runtime, either by the system or by using a test author recording it using
/// ``Issue/record(_:kind:)``.
case runtime
}

/// The kind of issue this value represents.
Expand Down Expand Up @@ -263,6 +267,8 @@ extension Issue.Kind: CustomStringConvertible {
return "An API was misused"
case .system:
return "A system failure occurred"
case .runtime:
return "A runtime issue occurred"
}
}
}
Expand Down Expand Up @@ -416,6 +422,10 @@ extension Issue.Kind {
/// An issue due to a failure in the underlying system, not due to a failure
/// within the tests being run.
case system

/// An issue which occurred during runtime, either by the system or by using a test author recording it using
/// ``Issue/record(_:kind:)``.
case runtime

/// Initialize an instance of this type by snapshotting the specified issue
/// kind.
Expand All @@ -440,6 +450,8 @@ extension Issue.Kind {
.apiMisused
case .system:
.system
case .runtime:
.runtime
}
}

Expand All @@ -453,6 +465,7 @@ extension Issue.Kind {
case knownIssueNotRecorded
case apiMisused
case system
case runtime

/// The keys used to encode ``Issue.Kind.expectationFailed``.
enum _ExpectationFailedKeys: CodingKey {
Expand Down Expand Up @@ -531,6 +544,8 @@ extension Issue.Kind {
try container.encode(true, forKey: .apiMisused)
case .system:
try container.encode(true, forKey: .system)
case .runtime:
try container.encode(true, forKey: .runtime)
}
}
}
Expand Down Expand Up @@ -585,6 +600,8 @@ extension Issue.Kind.Snapshot: CustomStringConvertible {
"An API was misused"
case .system:
"A system failure occurred"
case .runtime:
"A runtime issue occurred"
}
}
}
Expand Down