I’m building a library that contains inline tests with ppx_expect, and I’d like to be able to run ppx_expect only when dune runtest
is called.
The reason is that I’ve defined ppx-expect
as a with-test
dependency in my opam file, and I don’t want users to have to install ppx_expect (and all its dependencies) just to use the library. It’s defined in my opam file like:
depends: [
"dune" {>= "3.4"}
"yojson"
"containers"
"fmt"
"ppx_deriving"
"ppx_expect" {with-test}
I’m including ppx_expect it in my dune file, and I wonder if its possible to use a conditional so that ppx_expect isn’t needed outside of the dune runtest
alias.
I’ve tried the following, but dune gives a Error: unknown constructor if
error:
(library (name my_library)
(libraries fmt)
(inline_tests)
(preprocess (if (= %{inline_tests} enabled) (pps ppx_expect)))
)