Skip to content

Commit fc4226a

Browse files
committed
Add isolation to withExpectedIssue and withIssueContext
1 parent 9243488 commit fc4226a

File tree

6 files changed

+366
-164
lines changed

6 files changed

+366
-164
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# ``IssueReporting/withExpectedIssue(_:isIntermittent:fileID:filePath:line:column:_:)-9pinm``
1+
# ``IssueReporting/withExpectedIssue(_:isIntermittent:fileID:filePath:line:column:_:)``
22

33
## Topics
44

55
### Overloads
66

7-
- ``IssueReporting/withExpectedIssue(_:isIntermittent:fileID:filePath:line:column:_:)-7noz2``
7+
- ``IssueReporting/withExpectedIssue(_:isIntermittent:isolation:fileID:filePath:line:column:_:)``
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# ``IssueReporting/withIssueContext(fileID:filePath:line:column:operation:)-97lux``
1+
# ``IssueReporting/withIssueContext(fileID:filePath:line:column:operation:)``
22

33
## Topics
44

55
### Overloads
66

7-
- ``withIssueContext(fileID:filePath:line:column:operation:)-6o3dr``
7+
- ``withIssueContext(fileID:filePath:line:column:isolation:operation:)``

Sources/IssueReporting/Internal/SwiftTesting.swift

Lines changed: 139 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -166,73 +166,150 @@ func _withKnownIssue(
166166
withKnownIssue(message, isIntermittent, fileID, filePath, line, column, body)
167167
}
168168

169-
@usableFromInline
170-
func _withKnownIssue(
171-
_ message: String? = nil,
172-
isIntermittent: Bool = false,
173-
fileID: String = #fileID,
174-
filePath: String = #filePath,
175-
line: Int = #line,
176-
column: Int = #column,
177-
_ body: () async throws -> Void
178-
) async {
179-
guard let function = function(for: "$s25IssueReportingTestSupport010_withKnownA5AsyncypyF")
180-
else {
181-
#if DEBUG
182-
guard
183-
let withKnownIssue = unsafeBitCast(
184-
symbol: """
185-
$s7Testing14withKnownIssue_14isIntermittent14sourceLocation_yAA7CommentVSg_SbAA06Source\
186-
H0VyyYaKXEtYaFTu
187-
""",
188-
in: "Testing",
189-
to: (@convention(thin) (
190-
Any?,
191-
Bool,
192-
SourceLocation,
193-
() async throws -> Void
194-
) async -> Void)
195-
.self
169+
#if compiler(>=6.0.2)
170+
@usableFromInline
171+
func _withKnownIssue(
172+
_ message: String?,
173+
isIntermittent: Bool,
174+
isolation: isolated (any Actor)?,
175+
fileID: String,
176+
filePath: String,
177+
line: Int,
178+
column: Int,
179+
_ body: () async throws -> Void
180+
) async {
181+
guard
182+
let function = function(for: "$s25IssueReportingTestSupport010_withKnownA13AsyncIsolatedypyF")
183+
else {
184+
#if DEBUG
185+
guard
186+
let withKnownIssue = unsafeBitCast(
187+
symbol: """
188+
$s7Testing14withKnownIssue_14isIntermittent9isolation14sourceLocation_yAA7CommentVSg_\
189+
SbScA_pSgYiAA06SourceI0VyyYaKXEtYaF
190+
""",
191+
in: "Testing",
192+
to: (@convention(thin) (
193+
Any?,
194+
Bool,
195+
isolated (any Actor)?,
196+
SourceLocation,
197+
() async throws -> Void
198+
) async -> Void)
199+
.self
200+
)
201+
else { return }
202+
203+
var comment: Any?
204+
if let message {
205+
var c = UnsafeMutablePointer<Comment>.allocate(capacity: 1).pointee
206+
c.rawValue = message
207+
comment = c
208+
}
209+
await withKnownIssue(
210+
comment,
211+
isIntermittent,
212+
isolation,
213+
SourceLocation(fileID: fileID, _filePath: filePath, line: line, column: column),
214+
body
196215
)
197-
else { return }
216+
#else
217+
printError(
218+
"""
219+
\(fileID):\(line): A known issue was recorded without linking the Testing framework.
198220
199-
var comment: Any?
200-
if let message {
201-
var c = UnsafeMutablePointer<Comment>.allocate(capacity: 1).pointee
202-
c.rawValue = message
203-
comment = c
204-
}
205-
await withKnownIssue(
206-
comment,
207-
isIntermittent,
208-
SourceLocation(fileID: fileID, _filePath: filePath, line: line, column: column),
209-
body
210-
)
211-
#else
212-
printError(
213-
"""
214-
\(fileID):\(line): A known issue was recorded without linking the Testing framework.
221+
To fix this, add "IssueReportingTestSupport" as a dependency to your test target.
222+
"""
223+
)
224+
#endif
225+
return
226+
}
215227

216-
To fix this, add "IssueReportingTestSupport" as a dependency to your test target.
217-
"""
218-
)
219-
#endif
220-
return
228+
let withKnownIssue =
229+
function
230+
as! @Sendable (
231+
String?,
232+
Bool,
233+
isolated (any Actor)?,
234+
String,
235+
String,
236+
Int,
237+
Int,
238+
() async throws -> Void
239+
) async -> Void
240+
await withKnownIssue(message, isIntermittent, isolation, fileID, filePath, line, column, body)
221241
}
242+
#else
243+
@usableFromInline
244+
func _withKnownIssue(
245+
_ message: String?,
246+
isIntermittent: Bool,
247+
fileID: String,
248+
filePath: String,
249+
line: Int,
250+
column: Int,
251+
_ body: () async throws -> Void
252+
) async {
253+
guard let function = function(for: "$s25IssueReportingTestSupport010_withKnownA5AsyncypyF")
254+
else {
255+
#if DEBUG
256+
guard
257+
let withKnownIssue = unsafeBitCast(
258+
symbol: """
259+
$s7Testing14withKnownIssue_14isIntermittent14sourceLocation_yAA7CommentVSg_SbAA06Sour\
260+
ceH0VyyYaKXEtYaFTu
261+
""",
262+
in: "Testing",
263+
to: (@convention(thin) (
264+
Any?,
265+
Bool,
266+
SourceLocation,
267+
() async throws -> Void
268+
) async -> Void)
269+
.self
270+
)
271+
else { return }
272+
273+
var comment: Any?
274+
if let message {
275+
var c = UnsafeMutablePointer<Comment>.allocate(capacity: 1).pointee
276+
c.rawValue = message
277+
comment = c
278+
}
279+
await withKnownIssue(
280+
comment,
281+
isIntermittent,
282+
SourceLocation(fileID: fileID, _filePath: filePath, line: line, column: column),
283+
body
284+
)
285+
#else
286+
printError(
287+
"""
288+
\(fileID):\(line): A known issue was recorded without linking the Testing framework.
289+
290+
To fix this, add "IssueReportingTestSupport" as a dependency to your test target.
291+
"""
292+
)
293+
#endif
294+
return
295+
}
296+
297+
let withKnownIssue =
298+
function
299+
as! @Sendable (
300+
String?,
301+
Bool,
302+
String,
303+
String,
304+
Int,
305+
Int,
306+
() async throws -> Void
307+
) async -> Void
308+
await withKnownIssue(message, isIntermittent, fileID, filePath, line, column, body)
309+
}
310+
311+
#endif
222312

223-
let withKnownIssue =
224-
function
225-
as! @Sendable (
226-
String?,
227-
Bool,
228-
String,
229-
String,
230-
Int,
231-
Int,
232-
() async throws -> Void
233-
) async -> Void
234-
await withKnownIssue(message, isIntermittent, fileID, filePath, line, column, body)
235-
}
236313
@usableFromInline
237314
func _currentTestID() -> AnyHashable? {
238315
guard let function = function(for: "$s25IssueReportingTestSupport08_currentC2IDypyF")

0 commit comments

Comments
 (0)