Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jul 10, 2024
1 parent eaa3ad4 commit c29835d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
20 changes: 15 additions & 5 deletions Sources/IssueReporting/IssueContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ public struct IssueContext: Sendable {

/// The source `#column` to associate with an issue.
public let column: UInt


/// Creates source context for an issue with the calling context.
public static func issueContext(
fileID: StaticString = #fileID,
filePath: StaticString = #filePath,
line: UInt = #line,
column: UInt = #column
) -> Self {
Self(fileID: fileID, filePath: filePath, line: line, column: column)
}

/// Creates source context for an issue.
///
/// - Parameters:
Expand All @@ -23,10 +33,10 @@ public struct IssueContext: Sendable {
/// - line: The source `#line` to associate with an issue.
/// - column: The source `#column` to associate with an issue.
public init(
fileID: StaticString = #fileID,
filePath: StaticString = #filePath,
line: UInt = #line,
column: UInt = #column
fileID: StaticString,
filePath: StaticString,
line: UInt,
column: UInt
) {
self.fileID = fileID
self.filePath = filePath
Expand Down
2 changes: 1 addition & 1 deletion Sources/IssueReporting/ReportIssue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@_transparent
public func reportIssue(
_ message: @autoclosure () -> String = "",
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) {
switch TestContext.current {
case .swiftTesting:
Expand Down
10 changes: 5 additions & 5 deletions Sources/IssueReporting/Unimplemented.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public func unimplemented<each Argument, Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
function: StaticString = #function,
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) -> @Sendable (repeat each Argument) -> Result {
return { (argument: repeat each Argument) in
_fail(
Expand All @@ -35,7 +35,7 @@ public func unimplemented<each Argument, Result>(
public func unimplemented<each Argument, Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
function: StaticString = #function,
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) -> @Sendable (repeat each Argument) throws -> Result {
return { (argument: repeat each Argument) in
let description = description()
Expand All @@ -62,7 +62,7 @@ public func unimplemented<each Argument, Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
function: StaticString = #function,
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) -> @Sendable (repeat each Argument) async -> Result {
return { (argument: repeat each Argument) in
_fail(
Expand All @@ -87,7 +87,7 @@ public func unimplemented<each Argument, Result>(
public func unimplemented<each Argument, Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
function: StaticString = #function,
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) -> @Sendable (repeat each Argument) async throws -> Result {
return { (argument: repeat each Argument) in
let description = description()
Expand All @@ -106,7 +106,7 @@ public func unimplemented<Result>(
_ description: @autoclosure @escaping @Sendable () -> String = "",
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
function: StaticString = #function,
context issueContext: IssueContext = IssueContext()
context issueContext: IssueContext = .issueContext()
) -> Result {
_fail(
description(),
Expand Down
2 changes: 1 addition & 1 deletion Sources/IssueReporting/WithExpectedIssue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public func withExpectedIssue(
_ message: String? = nil,
isIntermittent: Bool = false,
context issueContext: IssueContext = IssueContext(),
context issueContext: IssueContext = .issueContext(),
_ body: () throws -> Void
) {
switch TestContext.current {
Expand Down
27 changes: 17 additions & 10 deletions Sources/XCTestDynamicOverlay/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ public func XCTFail(_ message: String = "", file: StaticString = #filePath, line
reportIssue(
message,
context: IssueContext(
fileID: XCTFailContext.current?.file ?? file,
filePath: XCTFailContext.current?.file ?? file,
line: XCTFailContext.current?.line ?? line
line: XCTFailContext.current?.line ?? line,
column: 0
)
)
}
Expand Down Expand Up @@ -298,7 +300,8 @@ public func unimplemented<each Argument, Result>(
context: IssueContext(
fileID: fileID,
filePath: filePath,
line: line
line: line,
column: 0
)
)
do {
Expand Down Expand Up @@ -491,11 +494,13 @@ public func XCTUnimplemented<each Argument, Result>(
unimplemented(
description(),
placeholder: placeholder(),
fileID: fileID,
filePath: filePath,
function: function,
line: line,
column: column
context: IssueContext(
fileID: fileID,
filePath: filePath,
line: line,
column: column
)
)
}

Expand Down Expand Up @@ -528,11 +533,13 @@ public func XCTUnimplemented<each Argument, Result>(
) -> @Sendable (repeat each Argument) throws -> Result {
unimplemented(
description(),
fileID: fileID,
filePath: filePath,
function: function,
line: line,
column: column
context: IssueContext(
fileID: fileID,
filePath: filePath,
line: line,
column: column
)
)
}

Expand Down

0 comments on commit c29835d

Please sign in to comment.