File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,17 +90,15 @@ public struct Test: Sendable {
9090 _properties. value. traits
9191 }
9292 set {
93- // Prevent programmatically adding suite traits to test functions or test
94- // traits to test suites.
95- func traitsAreCorrectlyTyped( ) -> Bool {
96- if isSuite {
97- return newValue. allSatisfy { $0 is any SuiteTrait }
98- } else {
99- return newValue. allSatisfy { $0 is any TestTrait }
100- }
93+ // When setting traits, we take care to only apply those that are
94+ // applicable. For example, if a trait only conforms to `SuiteTrait` and
95+ // not `TestTrait`, it should only be applied to suites, and not tests.
96+ let applicableTraits = if isSuite {
97+ newValue. filter { $0 is any SuiteTrait }
98+ } else {
99+ newValue. filter { $0 is any TestTrait }
101100 }
102- precondition ( traitsAreCorrectlyTyped ( ) , " Programmatically added an inapplicable trait to test \( self ) " )
103- _setValue ( newValue, forKeyPath: \. traits)
101+ _setValue ( applicableTraits, forKeyPath: \. traits)
104102 }
105103 }
106104
You can’t perform that action at this time.
0 commit comments