As far as I can tell are there no way to exclude all tests with a tag. Is this something which is feasable to add to spec and is there an intresset from other for such a feature (excluding myself)?
Pretty sure you can already do this via like crystal spec --tag '~slow'
. Which would run all specs not tagged with slow
.
I know but I want to be able to exclude all with tags. Without needing to specify which to exclude.
Ah gotcha, yea in that case I don’t think that’s something that is possible at the moment. Can you share a bit about your use case?
I have a situation where I would like to add optional tests to the Crystal track on Exercism. This would mean that a user can locally run all the tests togehter with the optional tests. But due to how the online platform is built up I can’t have an optional tests interface. Instead the best way would just be to disable all of the optional tests. Thereby it would be quite handy if I could just write --disable-tags
or something.
Maybe I’m not following 100%, but what do you need an interface for? Couldn’t you just add an optional
tag to all the optional specs? Then you could do like:
crystal spec
- runs required + optional testscrystal spec --tag optional
- Only run optional testscrystal spec --tag ~optional
- Only run required tests
That could be a solution, the issue which might appear is if I would like to have multiple optional tests. Like for example testing concurrency or unicode, and you might what to be able to test those seperatly. But as of now I don’t really have a need for that (maybe in the future though), so the optinal tag should actually work. Hadn’t thought about using the same optinal tag for all of the optinal tests.
Yup yup, should work well for this. Ideally you’d think of a tag as like a category.
I assume you can’t use focus
in this context? That would be a fairly idiomatic way of running an arbitrary subset of specs regardless of their tags. Otherwise, specs can have multiple tags, so as long as you use the tags only for the optional specs, can give a spec optional
and unicode
tags, so the user could either run all unicode specs, or all optional. But since the required ones wouldn’t have any tags they would be excluded by default.
Not sure if it applies, but you could also organize specs in other directories.
crystal spec
runs things from ./spec
, but you should be able to do crystal spec ./extra_spec
to run everything in ./extra_spec/**/*_spec.cr
IIRC.
And is possible to require everything from one into the other, so you could do ./spec and ./full_spec as directories.
Maybe the --example
option could also be useful. It filters based on the example description. No support for negative search (exclusion) though.