What's the best practice to make some tests only available on CI with dune?

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

1 Like

I have created an alias for those tests and run them with dune build @slow-tests-only-ci.

1 Like

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

 (alias runtest)
  (<> %{env:CI=false} "false"))
  (echo "running my slow test")))
1 Like

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:

 (name citest)
  (alias_rec perftest)
  (alias_rec runtest)))

Then you can do:

% dune build @citest
% dune build @perftest


1 Like