Running tests with dune without installing

For example if we have a directory structure like this:

pkg1/jbuild
pkg2/jbuild
pkg1_tests/jbuild
pkg2_tests/jbuild
pkg1.opam
pkg2.opam

Where pkg1_tests/jbuild and pkg2_tests/jbuild use pkg1 and pkg2 for linking or preprocessing. Is it possible to do dune runtest for pkg1_tests and pkg2_tests without installing pkg1 and pkg2 before?
Sadly I wasn’t able to find any information about this scenario in the tutorial.
For real world project - see https://github.com/mirage/ocaml-cstruct
It can be built with dune build - it will build both cstruct and ppx_cstruct, but it is impossible to run dune runtest in ppx_test without installing cstruct and ppx_cstruct first. And you can’t specify something like dune runtest -p ppx_test since there is no opam for ppx_test. What should I do?

You should run dune runtest from the root directory, so dune can see pkg1 and pkg2.
Dune will try to not build/run something if it is not necessary.
Try dune runtest pkg1_tests

1 Like