@@ -34,27 +34,33 @@ public func reportIssue(
34
34
line: UInt = #line,
35
35
column: UInt = #column
36
36
) {
37
+ let ( fileID, filePath, line, column) = (
38
+ IssueContext . current? . fileID ?? fileID,
39
+ IssueContext . current? . filePath ?? filePath,
40
+ IssueContext . current? . line ?? line,
41
+ IssueContext . current? . column ?? column
42
+ )
37
43
guard let context = TestContext . current else {
38
44
guard !isTesting else { return }
39
45
if let observer = FailureObserver . current {
40
46
observer. withLock { $0 += 1 }
41
47
for reporter in IssueReporters . current {
42
48
reporter. expectIssue (
43
49
message ( ) ,
44
- fileID: IssueContext . current ? . fileID ?? fileID,
45
- filePath: IssueContext . current ? . filePath ?? filePath,
46
- line: IssueContext . current ? . line ?? line,
47
- column: IssueContext . current ? . column ?? column
50
+ fileID: fileID,
51
+ filePath: filePath,
52
+ line: line,
53
+ column: column
48
54
)
49
55
}
50
56
} else {
51
57
for reporter in IssueReporters . current {
52
58
reporter. reportIssue (
53
59
message ( ) ,
54
- fileID: IssueContext . current ? . fileID ?? fileID,
55
- filePath: IssueContext . current ? . filePath ?? filePath,
56
- line: IssueContext . current ? . line ?? line,
57
- column: IssueContext . current ? . column ?? column
60
+ fileID: fileID,
61
+ filePath: filePath,
62
+ line: line,
63
+ column: column
58
64
)
59
65
}
60
66
}
@@ -65,16 +71,16 @@ public func reportIssue(
65
71
case . swiftTesting:
66
72
_recordIssue (
67
73
message: message ( ) ,
68
- fileID: " \( IssueContext . current ? . fileID ?? fileID) " ,
69
- filePath: " \( IssueContext . current ? . filePath ?? filePath) " ,
70
- line: Int ( IssueContext . current ? . line ?? line) ,
71
- column: Int ( IssueContext . current ? . column ?? column)
74
+ fileID: " \( fileID) " ,
75
+ filePath: " \( filePath) " ,
76
+ line: Int ( line) ,
77
+ column: Int ( column)
72
78
)
73
79
case . xcTest:
74
80
_XCTFail (
75
81
message ( ) . withAppHostWarningIfNeeded ( ) ?? " " ,
76
- file: IssueContext . current ? . filePath ?? filePath,
77
- line: IssueContext . current ? . line ?? line
82
+ file: filePath,
83
+ line: line
78
84
)
79
85
@unknown default : break
80
86
}
@@ -101,6 +107,12 @@ public func reportIssue(
101
107
line: UInt = #line,
102
108
column: UInt = #column
103
109
) {
110
+ let ( fileID, filePath, line, column) = (
111
+ IssueContext . current? . fileID ?? fileID,
112
+ IssueContext . current? . filePath ?? filePath,
113
+ IssueContext . current? . line ?? line,
114
+ IssueContext . current? . column ?? column
115
+ )
104
116
guard let context = TestContext . current else {
105
117
guard !isTesting else { return }
106
118
if let observer = FailureObserver . current {
@@ -109,21 +121,21 @@ public func reportIssue(
109
121
reporter. expectIssue (
110
122
error,
111
123
message ( ) ,
112
- fileID: IssueContext . current ? . fileID ?? fileID,
113
- filePath: IssueContext . current ? . filePath ?? filePath,
114
- line: IssueContext . current ? . line ?? line,
115
- column: IssueContext . current ? . column ?? column
124
+ fileID: fileID,
125
+ filePath: filePath,
126
+ line: line,
127
+ column: column
116
128
)
117
129
}
118
130
} else {
119
131
for reporter in IssueReporters . current {
120
132
reporter. reportIssue (
121
133
error,
122
134
message ( ) ,
123
- fileID: IssueContext . current ? . fileID ?? fileID,
124
- filePath: IssueContext . current ? . filePath ?? filePath,
125
- line: IssueContext . current ? . line ?? line,
126
- column: IssueContext . current ? . column ?? column
135
+ fileID: fileID,
136
+ filePath: filePath,
137
+ line: line,
138
+ column: column
127
139
)
128
140
}
129
141
}
@@ -135,16 +147,16 @@ public func reportIssue(
135
147
_recordError (
136
148
error: error,
137
149
message: message ( ) ,
138
- fileID: " \( IssueContext . current ? . fileID ?? fileID) " ,
139
- filePath: " \( IssueContext . current ? . filePath ?? filePath) " ,
140
- line: Int ( IssueContext . current ? . line ?? line) ,
141
- column: Int ( IssueContext . current ? . column ?? column)
150
+ fileID: " \( fileID) " ,
151
+ filePath: " \( filePath) " ,
152
+ line: Int ( line) ,
153
+ column: Int ( column)
142
154
)
143
155
case . xcTest:
144
156
_XCTFail (
145
157
" Caught error: \( error) \( message ( ) . map { " : \( $0) " } ?? " " ) " . withAppHostWarningIfNeeded ( ) ,
146
- file: IssueContext . current ? . filePath ?? filePath,
147
- line: IssueContext . current ? . line ?? line
158
+ file: filePath,
159
+ line: line
148
160
)
149
161
@unknown default : break
150
162
}
0 commit comments