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

Implement --test_filter support #999

Merged
merged 4 commits into from
Feb 16, 2023
Merged

Implement --test_filter support #999

merged 4 commits into from
Feb 16, 2023

Conversation

cwybro
Copy link
Contributor

@cwybro cwybro commented Feb 12, 2023

Description

Implement --test_filter support, as detailed in #997. This can be engaged via a swift_test target like so:

bazel test //:Tests --test_filter=TestModuleName.TestClassName/testMethodName

Note: If --test_filter is not passed into the test invocation, we fallback to the original behavior (pass All into the xctest invocation.

Changelog

  • IMPROVED:
    • Implement test_filter, allowing users to inject a specific test scope into swift_test execution

TODO

  • Add tests
  • Add docs (I'm open to updating / moving the new documentation as necessary)

@google-cla
Copy link

google-cla bot commented Feb 12, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@cwybro
Copy link
Contributor Author

cwybro commented Feb 14, 2023

@keith The current test suite validates the following:

  1. Tests fail without test filtering
  2. Test scope is reduced via test filtering

However 2 can currently be subverted if zero tests are executed (e.g. you specify a filter that matches no tests). Given this, I'd like to validate that the tests are actually executed, for example:

  • The test.log contains: Test Suite 'All tests' / Test Suite 'Selected tests'
  • The test.log contains: Executed 1 test, with 0 failures

Is it possible to write tests against the test log output (or another test artifact)? There might be a better way to assert against this output, or perhaps this is not a desirable test. Open to suggestions / feedback either way. Thanks!

@keith
Copy link
Member

keith commented Feb 14, 2023

blah yea, i think you might be able to with a shell test, but that is worse in other ways, so i think this is probably good enough for now

@cwybro cwybro marked this pull request as ready for review February 16, 2023 00:08
@keith keith merged commit a2dc454 into bazelbuild:master Feb 16, 2023
@keith
Copy link
Member

keith commented Feb 16, 2023

Thanks!

copybara-service bot pushed a commit that referenced this pull request Mar 3, 2023
This is loosely based on #999, but includes support for Linux as well as Apple platforms.

PiperOrigin-RevId: 513859254
tymurmustafaiev pushed a commit to tymurmustafaiev/rules_swift that referenced this pull request Jul 19, 2023
Implement `--test_filter` support, as detailed in
bazelbuild#997. This can be
engaged via a `swift_test` target like so:

```
bazel test //:Tests --test_filter=TestModuleName.TestClassName/testMethodName
```

**Note:** If `--test_filter` is not passed into the test invocation, we
fallback to the original behavior (pass `All` into the xctest
invocation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants