We have some tests which is time consuming, we want to enable it only on CI and occasionally turned it on locally.
What’s the best practice of doing that (assuming with the dune build system)? Thanks – Hongbo
I have created an alias for those tests and run them with dune build @slow-tests-only-ci
.
you should also be able to use enable_if
on your alias. For example you could only enable the rule if the env variable CI
is defined and is true.
This is something I want to try, but I could not find examples in the dune manual, do you have a working example? thanks
The search term is enabled_if
, you will find some results in the dune manual for that.
Another option if by chance you’re using Alcotest, it has built-in support for skipping slow tests: GitHub - mirage/alcotest: A lightweight and colourful test framework
I was aware of enabled_if
, not sure how it interacts with env variable though
(rule
(alias runtest)
(enabled_if
(<> %{env:CI=false} "false"))
(action
(echo "running my slow test")))
With liquidsoap
we have a special target that is a superset of the tests. This is because we expect the CI
tests to be run with some (almost all) optional dependencies.
We also have a superset of the test that are for performance tests only:
(alias
(name citest)
(deps
(alias_rec perftest)
(alias_rec runtest)))
Then you can do:
% dune build @citest
% dune build @perftest
etc…