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
Generated code for XCTest on non-Darwin needs to be actor-isolated. (#7566)
On Linux, Windows, etc. (anywhere that uses swift-corelibs-xctest
instead of XCTest.framework), SwiftPM is responsible for generating an
entry point function that passes in all tests discovered at compile
time. The compiler cannot tell whether the generated code is
concurrency-safe. This PR modifies the generated code and makes it
main-actor-isolated. Since it's only ever used in the program's main
function, this is safe.
Resolves#7556.
Copy file name to clipboardExpand all lines: Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -87,6 +87,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
87
87
88
88
fileprivate extension \#(className){
89
89
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
@@ -98,6 +99,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
98
99
content +=
99
100
#"""
100
101
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
@@ -166,6 +168,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
166
168
import XCTest
167
169
168
170
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
171
+
@MainActor
169
172
public func __allDiscoveredTests() -> [XCTestCaseEntry] {
170
173
\#(testsKeyword)tests = [XCTestCaseEntry]()
171
174
@@ -264,18 +267,15 @@ final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
264
267
@main
265
268
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
266
269
struct Runner {
267
-
#if os(WASI)
268
-
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.
269
270
static func main() async {
270
271
\#(testObservabilitySetup)
272
+
#if os(WASI)
273
+
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.
0 commit comments