From f93e39bbb17bd0e2db69f1df83a6f9c0fe8d9302 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Wed, 11 Sep 2024 14:08:06 -0400 Subject: [PATCH] Remove `@MainActor` from XCTest glue. Removes `@MainActor` and adds `nonisolated(unsafe)` to suppress concurrency diagnostics in the XCTest glue code generated when using corelibs-xctest. --- Sources/Build/LLBuildCommands.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sources/Build/LLBuildCommands.swift b/Sources/Build/LLBuildCommands.swift index bcac588c8ea..900bd37b1b7 100644 --- a/Sources/Build/LLBuildCommands.swift +++ b/Sources/Build/LLBuildCommands.swift @@ -76,8 +76,7 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand { fileprivate extension \#(className) { @available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings") - @MainActor - static let __allTests__\#(className) = [ + static nonisolated(unsafe) let __allTests__\#(className) = [ \#(testMethods.map(\.allTestsEntry).joined(separator: ",\n ")) ] } @@ -88,13 +87,12 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand { content += #""" @available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings") - @MainActor func __\#(module)__allTests() -> [XCTestCaseEntry] { return [ \#( testsByClassNames.map { "testCase(\($0.key).__allTests__\($0.key))" } .joined(separator: ",\n ") - ) + ) ] } """# @@ -163,7 +161,6 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand { import XCTest @available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings") - @MainActor public func __allDiscoveredTests() -> [XCTestCaseEntry] { \#(testsKeyword) tests = [XCTestCaseEntry]()