I have this project
|-- lib
| |-- foo
| | |-- bar.ml
| | |-- bar.mli
| | |-- baz.ml
| | |-- baz.mli
| | |-- dune
| |-- lib.ml
| |-- dune
|-- test
| |-- foo_test
| | |-- bar_test.ml
| | |-- baz_test.ml
| | |-- dune
| |-- lib_test.ml
| |-- dune
|-- dune-project
In each of the dune file
; lib/foo/dune
(library
(name foo))
; lib/dune
(library
(name lib)
(public_name lib))
; test/foo_test/dune
(test
(name foo_test)
(libraries alcotest foo))
; test/dune
(test
(name lib_test)
(libraries alcotest lib))
In the root, I tried to run dune utop lib
and I can see the modules
Foo__Bar
Foo.Bar
Foo__Baz
Foo.Baz
I tried to run dune runtest
and it says
2 | (name foo_test)
^^^^^^^^^^^^^^^^
Error: Module "Foo_test" doesn't exist.
I then try to create an empty file test/foo_test/foo_test.ml
, and do dune runtest
, it seems that nothing is happening. I have the Alcotest run function in the test/foo_test/bar_test.ml
and test/foo_test/baz_test.ml
I have a few question:
- Why it says module
Foo_test
doesn’t exist? I follow the same structure as in lib and it worked in lib - Why the test doesn’t run
- It seems that OCaml project structure is not that intuitive to me (coming from NodeJS), any resources I can read on this?
5 posts - 3 participants