Dune aliasing one executable over another

I’m working on testing within https://github.com/Cjen1/OcamlPaxos/tree/paxos_core.

The issue is that for that version if I run dune exec test/paxos_core.exe it actually runs test/log.ml.

Investigating further if I remove all the tests from test/paxos_core.ml (but not Alcotest_lwt.run) this effect disappears, additionally if I remove the Alcotest_lwt.run from test/log.ml it also disappears.

This is being built on dune 2.6.0 and ocaml 4.10.0.

To build the repo clone/pin github.com/cjen1/master, the rest should be git submodules.

By default, Alcotest runs exit at the end of a test suite. That’s possibly part of what’s going on here.

You may want to try passing ~and_exit:false to both instances of run to see if this behaviour changes.

1 Like

Thanks! That revealed the problem - it was executing both tests!

One of the test modules is named Log and one of the library modules was also called Log. By removing an open Ocamlpaxos at the top and then qualifying all the Log's that has fixed it.

I think that dune was pulling in any named modules to the executable and hence it had not only the test/paxos_core.ml module but also the test/log.ml module.

I’m not sure if this is expected behavior though? (though I can also imagine it being impossible to fix…)

1 Like