Skip to content

Commit c29835d

Browse files
committed
wip
1 parent eaa3ad4 commit c29835d

File tree

5 files changed

+39
-22
lines changed

5 files changed

+39
-22
lines changed

Sources/IssueReporting/IssueContext.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ public struct IssueContext: Sendable {
1414

1515
/// The source `#column` to associate with an issue.
1616
public let column: UInt
17-
17+
18+
/// Creates source context for an issue with the calling context.
19+
public static func issueContext(
20+
fileID: StaticString = #fileID,
21+
filePath: StaticString = #filePath,
22+
line: UInt = #line,
23+
column: UInt = #column
24+
) -> Self {
25+
Self(fileID: fileID, filePath: filePath, line: line, column: column)
26+
}
27+
1828
/// Creates source context for an issue.
1929
///
2030
/// - Parameters:
@@ -23,10 +33,10 @@ public struct IssueContext: Sendable {
2333
/// - line: The source `#line` to associate with an issue.
2434
/// - column: The source `#column` to associate with an issue.
2535
public init(
26-
fileID: StaticString = #fileID,
27-
filePath: StaticString = #filePath,
28-
line: UInt = #line,
29-
column: UInt = #column
36+
fileID: StaticString,
37+
filePath: StaticString,
38+
line: UInt,
39+
column: UInt
3040
) {
3141
self.fileID = fileID
3242
self.filePath = filePath

Sources/IssueReporting/ReportIssue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@_transparent
1717
public func reportIssue(
1818
_ message: @autoclosure () -> String = "",
19-
context issueContext: IssueContext = IssueContext()
19+
context issueContext: IssueContext = .issueContext()
2020
) {
2121
switch TestContext.current {
2222
case .swiftTesting:

Sources/IssueReporting/Unimplemented.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public func unimplemented<each Argument, Result>(
1111
_ description: @autoclosure @escaping @Sendable () -> String = "",
1212
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
1313
function: StaticString = #function,
14-
context issueContext: IssueContext = IssueContext()
14+
context issueContext: IssueContext = .issueContext()
1515
) -> @Sendable (repeat each Argument) -> Result {
1616
return { (argument: repeat each Argument) in
1717
_fail(
@@ -35,7 +35,7 @@ public func unimplemented<each Argument, Result>(
3535
public func unimplemented<each Argument, Result>(
3636
_ description: @autoclosure @escaping @Sendable () -> String = "",
3737
function: StaticString = #function,
38-
context issueContext: IssueContext = IssueContext()
38+
context issueContext: IssueContext = .issueContext()
3939
) -> @Sendable (repeat each Argument) throws -> Result {
4040
return { (argument: repeat each Argument) in
4141
let description = description()
@@ -62,7 +62,7 @@ public func unimplemented<each Argument, Result>(
6262
_ description: @autoclosure @escaping @Sendable () -> String = "",
6363
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
6464
function: StaticString = #function,
65-
context issueContext: IssueContext = IssueContext()
65+
context issueContext: IssueContext = .issueContext()
6666
) -> @Sendable (repeat each Argument) async -> Result {
6767
return { (argument: repeat each Argument) in
6868
_fail(
@@ -87,7 +87,7 @@ public func unimplemented<each Argument, Result>(
8787
public func unimplemented<each Argument, Result>(
8888
_ description: @autoclosure @escaping @Sendable () -> String = "",
8989
function: StaticString = #function,
90-
context issueContext: IssueContext = IssueContext()
90+
context issueContext: IssueContext = .issueContext()
9191
) -> @Sendable (repeat each Argument) async throws -> Result {
9292
return { (argument: repeat each Argument) in
9393
let description = description()
@@ -106,7 +106,7 @@ public func unimplemented<Result>(
106106
_ description: @autoclosure @escaping @Sendable () -> String = "",
107107
placeholder: @autoclosure @escaping @Sendable () -> Result = (),
108108
function: StaticString = #function,
109-
context issueContext: IssueContext = IssueContext()
109+
context issueContext: IssueContext = .issueContext()
110110
) -> Result {
111111
_fail(
112112
description(),

Sources/IssueReporting/WithExpectedIssue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public func withExpectedIssue(
3434
_ message: String? = nil,
3535
isIntermittent: Bool = false,
36-
context issueContext: IssueContext = IssueContext(),
36+
context issueContext: IssueContext = .issueContext(),
3737
_ body: () throws -> Void
3838
) {
3939
switch TestContext.current {

Sources/XCTestDynamicOverlay/Internal/Deprecations.swift

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ public func XCTFail(_ message: String = "", file: StaticString = #filePath, line
1515
reportIssue(
1616
message,
1717
context: IssueContext(
18+
fileID: XCTFailContext.current?.file ?? file,
1819
filePath: XCTFailContext.current?.file ?? file,
19-
line: XCTFailContext.current?.line ?? line
20+
line: XCTFailContext.current?.line ?? line,
21+
column: 0
2022
)
2123
)
2224
}
@@ -298,7 +300,8 @@ public func unimplemented<each Argument, Result>(
298300
context: IssueContext(
299301
fileID: fileID,
300302
filePath: filePath,
301-
line: line
303+
line: line,
304+
column: 0
302305
)
303306
)
304307
do {
@@ -491,11 +494,13 @@ public func XCTUnimplemented<each Argument, Result>(
491494
unimplemented(
492495
description(),
493496
placeholder: placeholder(),
494-
fileID: fileID,
495-
filePath: filePath,
496497
function: function,
497-
line: line,
498-
column: column
498+
context: IssueContext(
499+
fileID: fileID,
500+
filePath: filePath,
501+
line: line,
502+
column: column
503+
)
499504
)
500505
}
501506

@@ -528,11 +533,13 @@ public func XCTUnimplemented<each Argument, Result>(
528533
) -> @Sendable (repeat each Argument) throws -> Result {
529534
unimplemented(
530535
description(),
531-
fileID: fileID,
532-
filePath: filePath,
533536
function: function,
534-
line: line,
535-
column: column
537+
context: IssueContext(
538+
fileID: fileID,
539+
filePath: filePath,
540+
line: line,
541+
column: column
542+
)
536543
)
537544
}
538545

0 commit comments

Comments
 (0)