Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Nov 14, 2023

Right now, we're checking if tests are hidden in multiple places during execution. This is somewhat inefficient, but it's also error-prone because it means that we can create new code paths that don't correctly check for hidden tests.

This PR consolidates the checks for hidden tests to Configuration.testFilter itself. With this change, hidden tests are always filtered out by that filtering function regardless of what value it's set to. The only escape hatch—which we need for our own unit tests only—is to explicitly call the internal-only Configuration.setTestFilter(toMatch:includeHiddenTests:) and pass true.

Checklist:

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By making the argument here non-optional, we simplify the logic quite a bit. If a caller wants to reset the test filter, they can set it to { _ in true }, but in practice I don't think mutating a test filter in-flight is a concern for us.

Copy link
Contributor

Choose a reason for hiding this comment

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

okay!

Right now, we're checking if tests are hidden in multiple places during execution. This is somewhat inefficient, but it's also error-prone because it means that we can create new code paths that _don't_ correctly check for hidden tests.

This PR consolidates the checks for hidden tests to `Configuration.testFilter` itself. With this change, hidden tests are _always_ filtered out by that filtering function regardless of what value it's set to. The only escape hatch—which we need for our own unit tests only—is to explicitly call the internal-only `Configuration.setTestFilter(toMatch:includeHiddenTests:)` and pass `true`.
@grynspan grynspan force-pushed the jgrynspan/simplify-hidden-filtering branch from 03f1390 to 2442360 Compare November 14, 2023 14:38
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Linux

@grynspan
Copy link
Contributor Author

As @suzannaratcliff worked on this code recently, I'm waiting for her to also take a look before I merge.

@grynspan grynspan merged commit e9d8acf into main Nov 14, 2023
@grynspan grynspan deleted the jgrynspan/simplify-hidden-filtering branch November 14, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants