kaocha
kaocha copied to clipboard
Mixing --focus and --focus-meta
It looks like that mixing arguments like --focus my.namespace and --focus-meta :meta-tag doesn't currently work as expected, which imho is applying both filters.
If that's not supported on purpose maybe it could at leat give an error after it parsed the arguments?
Filters form a logical "or". Combining them will match any test that matches any of the filters.
Ah ok I see, I guess it makes sense, it just means there is no way to do an and on the filters then?
The use case we kind of have is a lein alias like
{"integration-test" ["kaocha" "--focus-meta" ":integration"]}
but sometimes it would be good to run integration tests just for one namespace, and using an existing alias like that one it's not really possible, right?
In short, no. Implementing "AND" behavior would actually be easier than implementing OR, I went with the current behavior to allow --focus my.first.ns --focus my.second.ns and have them both run. Most of the logic in the filter plugin is to support this, and to combine somewhat intuitively with --skip/--skip-meta (e.g. when you focus on one ns, but then skip certain tests in that ns).
Now if you want this specific behavior then adding your own plugin would be fairly straightforward. All the filter plugin does is recursively walk over the tree of testables (suite/ns/var), and mark certain ones with :kaocha.testable/skip true. You could add a --focus-integration flag for instance. You can see an example of how to add an extra CLI flag in the notifier plugin, and then have a post-load step that marks tests to be skipped.
Yes ok sounds good, I guess the only way without a custom plugin would be to support something like
--and --focus-meta ... --focus ...
but it just gets overcomplicated and probably it's not an important use case anyway.