Skip to content
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

Make Configuration.TestFilter a pure-data type #358

Merged
merged 3 commits into from May 6, 2024

Conversation

stmontgomery
Copy link
Contributor

@stmontgomery stmontgomery commented Apr 17, 2024

This modifies the structure of Configuration.TestFilter so that it's a pure data type and is easier to become serializable.

Motivation:

For easier integration with tools it would be helpful for the stored properties of Configuration to be serializable, or be trivially convertible to/from serializable types at least.

Configuration's nested TestFilter type currently includes a closure for filtering tests and is therefore cannot be serialized in its current form. This type doesn't really need to store a closure, however; it only needs to store information about how to perform filtering (e.g. data about criteria to match against), and later that can be interpreted when applying filtering.

Modifications:

  • Change the Configuration.TestFilter.Kind enum so that its cases only store data, and no closures.
  • Move the filtering logic derived from the pure data Kind type above to a new Configuration.TestFilter.Operation enum.

Checklist:

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

Resolves rdar://126627664

@stmontgomery stmontgomery added enhancement New feature or request tools integration Integration of swift-testing into tools/IDEs labels Apr 17, 2024
@stmontgomery stmontgomery self-assigned this Apr 17, 2024
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

func apply(to testGraph: Graph<String, Test?>) -> Graph<String, Test?> {
var result = _kind.apply(to: testGraph)
func apply(to testGraph: Graph<String, Test?>) throws -> Graph<String, Test?> {
var result = try Operation(_predicate).apply(to: testGraph)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever need to separate Operation from apply(to:)? If not, can we just absorb the former into apply(to:)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean e.g. inline Operation enum into this function? I considered that but felt it would make the function body quite a bit more complicated. As it stands we're using access control to scope it pretty narrowly

Copy link
Contributor

Choose a reason for hiding this comment

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

We could still split up the implementation into multiple functions/steps, but keep the interface simple.

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery stmontgomery changed the title Make Configuration.TestFilter Codable Make Configuration.TestFilter a pure-data type May 6, 2024
@stmontgomery stmontgomery merged commit c105aa1 into main May 6, 2024
3 checks passed
@stmontgomery stmontgomery deleted the codable-configuration branch May 6, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tools integration Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants