You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The exit test that is running in the current process, if any.
137
140
///
@@ -144,11 +147,13 @@ extension ExitTest {
144
147
/// process.
145
148
publicstaticvarcurrent:ExitTest?{
146
149
_read{
147
-
iflet current = _current.rawValue {
148
-
yield current.exitTest
149
-
}else{
150
-
yield nil
150
+
// NOTE: Even though this accessor is `_read` and has borrowing semantics,
151
+
// we must make a copy so that we don't yield lock-guarded memory to the
152
+
// caller (which is not concurrency-safe.)
153
+
letcurrentCopy= _current.withLock{ current in
154
+
return current.pointee?.unsafeCopy()
151
155
}
156
+
yield currentCopy
152
157
}
153
158
}
154
159
}
@@ -235,7 +240,8 @@ extension ExitTest {
235
240
236
241
// Set ExitTest.current before the test body runs.
237
242
Self._current.withLock{ current in
238
-
current =_CurrentContainer(exitTest:self)
243
+
precondition(current.pointee ==nil,"Set the current exit test twice in the same process. Please file a bug report at https://github.com/swiftlang/swift-testing/issues/new")
0 commit comments