1919/// - ``Trait/disabled(if:_:sourceLocation:)``
2020/// - ``Trait/disabled(_:sourceLocation:_:)``
2121public struct ConditionTrait : TestTrait , SuiteTrait {
22- /// An optional, user-specified comment describing this trait.
23- public var comment : Comment ?
24-
2522 /// An enumeration describing the kinds of conditions that can be represented
2623 /// by an instance of this type.
2724 enum Kind : Sendable {
@@ -68,6 +65,7 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
6865 /// If this trait was created using a function such as
6966 /// ``enabled(if:_:sourceLocation:)`` that is evaluated at runtime, the value
7067 /// of this property is `false`.
68+ @_spi ( ForToolsIntegrationOnly)
7169 public var isConstant : Bool {
7270 switch kind {
7371 case . conditional:
@@ -77,6 +75,8 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
7775 }
7876 }
7977
78+ public var comments : [ Comment ]
79+
8080 /// The source location where this trait was specified.
8181 public var sourceLocation : SourceLocation
8282
@@ -93,17 +93,13 @@ public struct ConditionTrait: TestTrait, SuiteTrait {
9393
9494 if !result {
9595 let sourceContext = SourceContext ( sourceLocation: sourceLocation)
96- throw SkipInfo ( comment: commentOverride ?? comment , sourceContext: sourceContext)
96+ throw SkipInfo ( comment: commentOverride ?? comments . first , sourceContext: sourceContext)
9797 }
9898 }
9999
100100 public var isRecursive : Bool {
101101 true
102102 }
103-
104- public var comments : [ Comment ] {
105- Array ( comment)
106- }
107103}
108104
109105// MARK: -
@@ -132,7 +128,7 @@ extension Trait where Self == ConditionTrait {
132128 _ comment: Comment ? = nil ,
133129 sourceLocation: SourceLocation = #_sourceLocation
134130 ) -> Self {
135- Self ( comment : comment , kind: . conditional( condition) , sourceLocation: sourceLocation)
131+ Self ( kind: . conditional( condition) , comments : Array ( comment ) , sourceLocation: sourceLocation)
136132 }
137133
138134 /// Construct a condition trait that causes a test to be disabled if it
@@ -152,7 +148,7 @@ extension Trait where Self == ConditionTrait {
152148 sourceLocation: SourceLocation = #_sourceLocation,
153149 _ condition: @escaping @Sendable ( ) async throws -> Bool
154150 ) -> Self {
155- Self ( comment : comment , kind: . conditional( condition) , sourceLocation: sourceLocation)
151+ Self ( kind: . conditional( condition) , comments : Array ( comment ) , sourceLocation: sourceLocation)
156152 }
157153
158154 /// Construct a condition trait that disables a test unconditionally.
@@ -167,7 +163,7 @@ extension Trait where Self == ConditionTrait {
167163 _ comment: Comment ? = nil ,
168164 sourceLocation: SourceLocation = #_sourceLocation
169165 ) -> Self {
170- Self ( comment : comment , kind: . unconditional( false ) , sourceLocation: sourceLocation)
166+ Self ( kind: . unconditional( false ) , comments : Array ( comment ) , sourceLocation: sourceLocation)
171167 }
172168
173169 /// Construct a condition trait that causes a test to be disabled if it
@@ -193,7 +189,7 @@ extension Trait where Self == ConditionTrait {
193189 _ comment: Comment ? = nil ,
194190 sourceLocation: SourceLocation = #_sourceLocation
195191 ) -> Self {
196- Self ( comment : comment , kind: . conditional { !( try condition ( ) ) } , sourceLocation: sourceLocation)
192+ Self ( kind: . conditional { !( try condition ( ) ) } , comments : Array ( comment ) , sourceLocation: sourceLocation)
197193 }
198194
199195 /// Construct a condition trait that causes a test to be disabled if it
@@ -213,6 +209,6 @@ extension Trait where Self == ConditionTrait {
213209 sourceLocation: SourceLocation = #_sourceLocation,
214210 _ condition: @escaping @Sendable ( ) async throws -> Bool
215211 ) -> Self {
216- Self ( comment : comment , kind: . conditional { !( try await condition ( ) ) } , sourceLocation: sourceLocation)
212+ Self ( kind: . conditional { !( try await condition ( ) ) } , comments : Array ( comment ) , sourceLocation: sourceLocation)
217213 }
218214}
0 commit comments