Skip to content

Commit 095d00e

Browse files
committed
Allow async traits on suites.
As a small follow-up to #32, ensure callers can specify `async` traits on suites too.
1 parent 68d7f88 commit 095d00e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Sources/TestingMacros/SuiteDeclarationMacro.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ public struct SuiteDeclarationMacro: MemberMacro, PeerMacro, Sendable {
159159
@available(*, unavailable, message: "This type is an implementation detail of the testing library. It cannot be used directly.")
160160
@available(*, deprecated)
161161
@frozen public enum \(enumName): Testing.__TestContainer {
162-
public static var __tests: [Testing.Test] {[
163-
.__type(
164-
\(declaration.type.trimmed).self,
165-
\(raw: attributeInfo.functionArgumentList(in: context))
166-
)
167-
]}
162+
public static var __tests: [Testing.Test] {
163+
get async {[
164+
.__type(
165+
\(declaration.type.trimmed).self,
166+
\(raw: attributeInfo.functionArgumentList(in: context))
167+
)
168+
]}
169+
}
168170
}
169171
"""
170172
)

Tests/TestingTests/MiscellaneousTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,15 @@ struct TestsWithStaticMemberAccessBySelfKeyword {
172172
@Test(.hidden, arguments: [0]) func A(🙃: Int) {}
173173
@Test(.hidden, arguments: [0]) func A(🙂: Int) {}
174174

175-
@Suite(.hidden)
175+
func asyncTrait() async -> some SuiteTrait & TestTrait {
176+
.comment("")
177+
}
178+
179+
@Suite(.hidden, await asyncTrait())
176180
struct TestsWithAsyncArguments {
177181
static func asyncCollection() async -> [Int] { [] }
178182

179-
@Test(.hidden, arguments: await asyncCollection()) func f(i: Int) {}
183+
@Test(.hidden, await asyncTrait(), arguments: await asyncCollection()) func f(i: Int) {}
180184
}
181185

182186
@Suite("Miscellaneous tests")

0 commit comments

Comments
 (0)