Skip to content

Commit 06f8984

Browse files
authored
Remove @MainActor from XCTest glue. (#7967)
Removes `@MainActor` and adds `nonisolated(unsafe)` to suppress concurrency diagnostics in the XCTest glue code generated when using corelibs-xctest. See also #7960.
1 parent 740a6c5 commit 06f8984

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Sources/Build/LLBuildCommands.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
7676
7777
fileprivate extension \#(className) {
7878
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
79-
@MainActor
80-
static let __allTests__\#(className) = [
79+
static nonisolated(unsafe) let __allTests__\#(className) = [
8180
\#(testMethods.map(\.allTestsEntry).joined(separator: ",\n "))
8281
]
8382
}
@@ -88,13 +87,12 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
8887
content +=
8988
#"""
9089
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
91-
@MainActor
9290
func __\#(module)__allTests() -> [XCTestCaseEntry] {
9391
return [
9492
\#(
9593
testsByClassNames.map { "testCase(\($0.key).__allTests__\($0.key))" }
9694
.joined(separator: ",\n ")
97-
)
95+
)
9896
]
9997
}
10098
"""#
@@ -163,7 +161,6 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
163161
import XCTest
164162
165163
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
166-
@MainActor
167164
public func __allDiscoveredTests() -> [XCTestCaseEntry] {
168165
\#(testsKeyword) tests = [XCTestCaseEntry]()
169166

0 commit comments

Comments
 (0)