I am getting the sense from the documentation of dune that a custom test
and an executable
are roughly the same things, however I am very puzzled by various differences which make it hard for me to do what I want. I have several questions but let me first describe the setting (this is organized in a somewhat bizarre way, I will tidy it up later):
myproject/
| lib/
| dune
| mylib/
...
| test/
| mytest.ml
| example.json
In mytest.ml
, I have a with_open_bin "example.json"
.
In myproject/lib/dune
:
(subdir mylib
(library
(name mylib)
...))
(subdir test
(test
(name mytest)
(libraries ... mylib)
(deps "example.json")))
So far so good. dune runtest lib/test
compiles and runs my test, correctly picking up example.json
. However, I would like to pass command line arguments to my test. This requires me to identify the specific test and not just the directory, but I was only able to do that using dune exec lib/test/mytest.exe -- ARGS
. This compiles and runs but when I do this, the file example.json
is evidently not visible to the program anymore. So my questions are:
- How to ensure
examples.json
is in the right place when usingexec
? - How to run an individual test with
runtest
? None ofdune runtest lib/test/mytest.exe
,dune runtest lib/test/mytest
,dune runtest lib/test/mytest.ml
anddune runtest mytest
work. - How to pass (non-constant) arguments to a test when using
runtest
?