Skip to content

Commit d17f3a7

Browse files
committed
Decode captured values within the same scope as the body so that we don't need to figure out a source location
1 parent 46ee2aa commit d17f3a7

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Diff for: Sources/Testing/ExitTests/ExitTest.swift

+6-10
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public struct ExitTest: Sendable, ~Copyable {
6060
/// Do not invoke this closure directly. Instead, invoke ``callAsFunction()``
6161
/// to run the exit test. Running the exit test will always terminate the
6262
/// current process.
63-
fileprivate var body: @Sendable (_ exitTest: borrowing Self) async throws -> Void = { _ in }
63+
fileprivate var body: @Sendable (_ exitTest: inout Self) async throws -> Void = { _ in }
6464

6565
/// Storage for ``observedValues``.
6666
///
@@ -251,7 +251,7 @@ extension ExitTest {
251251
}
252252

253253
do {
254-
try await body(self)
254+
try await body(&self)
255255
} catch {
256256
_errorInMain(error)
257257
}
@@ -307,7 +307,7 @@ extension ExitTest: DiscoverableAsTestContent {
307307

308308
// Wrap the body function in a thunk that decodes any captured state and
309309
// passes it along.
310-
let body: @Sendable (borrowing ExitTest) async throws -> Void = { exitTest in
310+
let body: @Sendable (inout Self) async throws -> Void = { exitTest in
311311
let values: (repeat each T) = try exitTest.capturedValues.takeCapturedValues()
312312
try await body(repeat each values)
313313
}
@@ -492,7 +492,7 @@ extension ExitTest {
492492
/// are available or the child environment is otherwise terminated. The parent
493493
/// environment is then responsible for interpreting those results and
494494
/// recording any issues that occur.
495-
public typealias Handler = @Sendable (_ exitTest: borrowing ExitTest) async throws -> ExitTest.Result
495+
public typealias Handler = @Sendable (_ exitTest: borrowing Self) async throws -> ExitTest.Result
496496

497497
/// Make a file handle from the string contained in the given environment
498498
/// variable.
@@ -615,14 +615,10 @@ extension ExitTest {
615615
}
616616
}
617617

618-
// TODO: get correct source location
619-
Issue.withErrorRecording(at: .__here(), configuration: configuration) {
620-
try result._decodeCapturedValuesForEntryPoint()
621-
}
622-
623618
result.body = { [configuration, body = result.body] exitTest in
624619
try await Configuration.withCurrent(configuration) {
625-
try await body(exitTest)
620+
try exitTest._decodeCapturedValuesForEntryPoint()
621+
try await body(&exitTest)
626622
}
627623
}
628624
return result

0 commit comments

Comments
 (0)