From 9ba504e075f5989d606ded77e8e3f3c1505886d6 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Sun, 29 Sep 2024 11:35:15 -0400 Subject: [PATCH] Fix macro expansion failure for a non-copyable suite type with a `test` method. If a non-copyable suite type has a test function whose name starts with `test`, we emit a call to `__invokeXCTestCaseMethod()` that's a no-op (but we can't tell during macro expansion if it will be.) This function needs to be updated to accept a non-copyable generic type. --- Sources/Testing/Test+Macro.swift | 2 +- Tests/TestingTests/NonCopyableSuiteTests.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Testing/Test+Macro.swift b/Sources/Testing/Test+Macro.swift index 50afa755d..637256b16 100644 --- a/Sources/Testing/Test+Macro.swift +++ b/Sources/Testing/Test+Macro.swift @@ -568,7 +568,7 @@ public func __ifMainActorIsolationEnforced( _ selector: __XCTestCompatibleSelector?, onInstanceOf type: T.Type, sourceLocation: SourceLocation -) async throws -> Bool { +) async throws -> Bool where T: ~Copyable { false } diff --git a/Tests/TestingTests/NonCopyableSuiteTests.swift b/Tests/TestingTests/NonCopyableSuiteTests.swift index 56a530199..6e70cab24 100644 --- a/Tests/TestingTests/NonCopyableSuiteTests.swift +++ b/Tests/TestingTests/NonCopyableSuiteTests.swift @@ -16,6 +16,7 @@ struct NonCopyableTests: ~Copyable { @Test borrowing func borrowMe() {} @Test consuming func consumeMe() {} @Test mutating func mutateMe() {} + @Test borrowing func testNotAnXCTestCaseMethod() {} @Test borrowing func typeComparison() { let lhs = TypeInfo(describing: Self.self)