I am having an issue where inline tests depend upon static files located outside the src
directory since jbuilder
runs tests from within that directory. Take for example the following:
inline test located in foo/src/foo.ml
depends upon foo/static/file.file
The solution I have come upon is to add a deps
clause to the the inline_tests
stanza that copies the static
folder. This creates a directory structure in the _build
that mirrors what exists in the repo. So, in my tests, I would access that file relatively via ../static/file.file
.
However, it seems wrong to have to do this for every static directory being used, is there a recommended way to do this?
Should I move static
into src
? I’m not sure that would solve the issue of having to specify every directory to be copied.
Or is there a way to specify which directory the tests should be run from? Perhaps a setting to run the tests from the workspace root? I see that jbuilder
does:
cd _build/default/foo/src && ./.foo.inline-tests/run.exe
Having it run in the root would also solve my problems since no copying is needed and foo/static
can be referenced directly.