@@ -137,38 +137,38 @@ public struct Configuration: Sendable {
137137
138138 // MARK: - Test selection
139139
140- /// The selected tests to run, if any .
140+ /// A function that handles filtering tests .
141141 ///
142- /// This property should be used for testing membership (whether a test ID has
143- /// been selected) since it is more optimized for that use case. It also
144- /// provides the backing storage for ``selectedTestIDs``.
145- ///
146- /// This property is optional and defaults to `nil` because it is possible to
147- /// select specific tests to run but not provide any tests in that list. That
148- /// is a supported use case: it results in zero tests being run and no issues
149- /// recorded.
150- ///
151- /// A practical example of when this situation can happen is when testing is
152- /// configured via an Xcode Test Plan, the "Automatically Include New Tests"
153- /// option is disabled, and zero tests are enabled.
154- var selectedTests : Test . ID . Selection ?
155-
156- /// The IDs of the selected tests to run, if any.
157- ///
158- /// This property is optional and defaults to `nil` because it is possible to
159- /// select specific tests to run but not provide any tests in that list. That
160- /// is a supported use case: it results in zero tests being run and no issues
161- /// recorded.
142+ /// - Parameters:
143+ /// - test: An test that needs to be filtered.
144+ ///
145+ /// - Returns: A Boolean value representing if the test satisfied the filter.
146+ public typealias TestFilter = @Sendable ( Test ) -> Bool
147+
148+ /// The test filter to which tests should be filtered when run.
149+ public var testFilter : TestFilter ?
150+
151+ /// The granularity to enforce test filtering.
152+ ///
153+ /// By default, all tests are run and no filter is set.
154+ /// - Parameters:
155+ /// - selection: An set of test ids to be filtered.
156+ public mutating func setTestFilter( toMatch selection: Set < Test . ID > ? ) {
157+ self . setTestFilter ( toMatch: selection. map ( Test . ID. Selection. init) )
158+ }
159+
160+ /// The granularity to enforce test filtering.
162161 ///
163- /// A practical example of when this situation can happen is when testing is
164- /// configured via an Xcode Test Plan, the "Automatically Include New Tests"
165- /// option is disabled, and zero tests are enabled.
166- public var selectedTestIDs : Set < Test . ID > ? {
167- get {
168- selectedTests? . testIDs
162+ /// By default, all tests are run and no filter is set.
163+ /// - Parameters:
164+ /// - selection: An selection of test ids to be filtered.
165+ mutating func setTestFilter( toMatch selection: Test . ID . Selection ? ) {
166+ guard let selectedTests = selection else {
167+ self . testFilter = nil
168+ return
169169 }
170- set {
171- selectedTests = newValue . map { . init ( testIDs : $0 ) }
170+ self . testFilter = { test in
171+ selectedTests . contains ( test )
172172 }
173173 }
174174}
0 commit comments