Skip to content

Commit a1301c6

Browse files
authored
Avoid Regex API availability check when no filter or skip flags have been passed (#410)
Fix several test failures in `SwiftPMTests` when running on older Apple OS versions before `Regex` was added, which is due to unnecessarily checking whether that API is available. One example: ```text ✘ Test "No --filter or --skip argument" recorded an issue at SwiftPMTests.swift:40:4: Caught error: The `--filter' option is not supported on this OS version. ``` In tests which do not involve `--filter` or `--skip` arguments, this check is unnecessary and can be avoided altogether. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 35b34ed commit a1301c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: Sources/Testing/EntryPoints/EntryPoint.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
313313
// Filtering
314314
var filters = [Configuration.TestFilter]()
315315
func testFilter(forRegularExpressions regexes: [String]?, label: String, membership: Configuration.TestFilter.Membership) throws -> Configuration.TestFilter {
316-
guard let regexes else {
316+
guard let regexes, !regexes.isEmpty else {
317+
// Return early if empty, even though the `reduce` logic below can handle
318+
// this case, in order to avoid the `#available` guard.
317319
return .unfiltered
318320
}
319321

0 commit comments

Comments
 (0)