Skip to content

Support filtering or selecting tests by filename #323

@reify-tanner-stirrat

Description

@reify-tanner-stirrat

The use case

CircleCI has functionality for getting a list of test names and then distributing them across parallel test runners. It's relatively easy to make this work with test runners in other languages, because many of them provide functionality for providing a list of test files to be interpreted and run by the runner. I'd like to be able to use this somehow.

Additionally, focusing by file would make it relatively easy to quickly run a subset of tests just based on file structure from the command line without modifying any files, which to my knowledge isn't possible.

Existing workarounds

Writing a kaocha entrypoint that bashes out to the CircleCI binary

You can see an example of it here: https://andreacrotti.github.io/2020-07-28-parallel-ci-kaocha/

This feels brittle compared to providing an arglist - it's structuring a runner around shelling out rather than providing an external interface that can be piped or arg'd in.

Writing a plugin

I've currently gone this route. I was able to write a plugin that takes --focus-files and then hacks the options of kaocha.plugin/filter to provide ns filtering indirectly. This works but is brittle because it depends on the order of plugin application.

I could also go and reimplement enough of the filter plugin's functionality to make the plugin self-contained, but that seems like a duplication of effort.

Proposed solutions

Add --focus-files as an option to the filter plugin

This could live in the filter plugin and use some of plugin's existing functionality. It seems to fit with the concepts of the other filter mechanisms.

Make fully-qualified files valid entries for :test-paths

If fully-qualified files were an option here, it would be possible to write a plugin that takes a --focus-files (or similar) argument and updates the :test-paths vector with those files. This seems like it would have an additional benefit of cutting down on the number of namespaces that are actually loaded by the framework before tests begin.

Conclusion

Let me know if any of these approaches is better than another in your eyes. I'm happy to provide a PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions