Skip to content

Replace setTestFilter with makeTestFilter. #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Dec 5, 2023

setTestFilter is too rigid because it replaces the existing test filter and that makes composition harder than it needs to be. Let's replace it with a function that returns a test filter which can then be composed:

let idFilter = makeTestFilter(matching: myTestIDs)
func canHaveAPony(_ test: Test) -> Bool { ... }
configuration.testFilter = { test in
  idFilter(test) && canHaveAPony(test)
}

Resolves rdar://119205417.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

`setTestFilter` is too rigid because it replaces the existing test filter and that makes composition harder than it needs to be. Let's replace it with a function that returns a test filter which can then be composed:

```swift
let idFilter = makeTestFilter(matching: myTestIDs)
func canHaveAPony(_ test: Test) -> Bool { ... }
configuration.testFilter = { test in
  idFilter(test) && canHaveAPony(test)
}
```

Resolves rdar://119205417.
@grynspan
Copy link
Contributor Author

grynspan commented Dec 5, 2023

@swift-ci please test


// MARK: - Test filter factory functions

/// Filter tests to run to those specified via a set of test IDs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the wording of these two factory functions? Now, they don't perform the filtering, but only generate a filter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sure.

Copy link
Contributor

@stmontgomery stmontgomery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from documentation suggestion

@grynspan
Copy link
Contributor Author

grynspan commented Dec 5, 2023

@swift-ci please test

@grynspan grynspan merged commit ced8b73 into main Dec 5, 2023
@grynspan grynspan deleted the jgrynspan/119205417-make-test-filter branch December 5, 2023 21:09
@stmontgomery stmontgomery added the tools integration 🛠️ Integration of swift-testing into tools/IDEs label Dec 5, 2023
grynspan added a commit that referenced this pull request Dec 5, 2023
This PR refines the previous PR for this issue, #153. It removes the internal overload of `makeTestFilter(matching:uncheckedTestFilter:)` because it is redundant: since the result needs to be passed to `uncheckedTestFilter` to preserve its lack of `isHidden`-checking, it doesn't _also_ need to impose its own check.

I did add an internal overload of `makeTestFilter()` to the test target that just returns `selection.contains` as a convenience.

Resolves rdar://119205417 (again.)
@grynspan grynspan mentioned this pull request Dec 5, 2023
2 tasks
grynspan added a commit that referenced this pull request Dec 5, 2023
* Refine `makeTestFilter()` further.

This PR refines the previous PR for this issue, #153. It removes the internal overload of `makeTestFilter(matching:uncheckedTestFilter:)` because it is redundant: since the result needs to be passed to `uncheckedTestFilter` to preserve its lack of `isHidden`-checking, it doesn't _also_ need to impose its own check.

I did add an internal overload of `makeTestFilter()` to the test target that just returns `selection.contains` as a convenience.

Resolves rdar://119205417 (again.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools integration 🛠️ Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants