I have a project built in Dune, with the structure
| project_dir -| bin | dune | main.ml -| lib | dune | libfile.ml -| test | dune | test.ml | data.csv
The libfile.ml
reads the data in data.csv
just fine, with a relative file path parallel to the current working directory (i.e., when main.ml
runs, libfile.ml
finds data.csv
at the root of the project directory).
However, when I call dune test
, it cannot find the file. I tried resolving this by adding the files to the ./test/dune
dependencies. But when doing that, the files have to be referenced relative to the ./test
directory! In order for the tests to find files, I need to give the path ../data.csv
.
So basically, one file path works for running and a different file path works for testing. I know that I could make all function calls take a file path argument and specify different paths in different places, but I am giving a very simplified description of the project, because it is quite large. Given how complex the project is, it would be much better if I could somehow either control the "current working directory" of the test or main execution, so that I could make one match the other.
Thanks for any help!