Does bisect_ppx work with dynamic libraries
I have some questions about using bisect_ppx and was hoping you could help!
It works fine for regular library modules, and I can generate coverage files without any problems. But when I try to use bisect_ppx with dynamic libraries (like .cmxs files) that are loaded into the main program using Dynlink, no coverage files get generated. Any idea why this happens? Does bisect_ppx not support dynamic libraries yet?
Is Bisect_ppx applied to the dynamic libraries when they are compiled (preprocessed, actually)?
I think Bisect should support dynamic libraries, as long as they are also compiled with Bisect enabled.
Do you have a small example of your setup?
I compiled the dynamic library with the config "(instrumentation (backend bisect_ppx))" in plugin/dune file. Is this not enough? How can I inspect whether the compiled libraries are preprocessed by bisect_ppx?
I have made a tarball bisect_test.tar.gz of my minimized dune project that uses dynlink, for your convinience to see where I did wrong. Build :
dune build --instrument-with bisect_ppx
run:
cd _build/default
bin/main.exe plugin/plugin.cmxs
Thank you! I downloaded the project and ran it with these commands:
rm -rf *.coverage
dune build --root . --instrument-with bisect_ppx
_build/default/bin/main.exe _build/default/plugin/plugin.cmxs
bisect-ppx-report html
This produced *.coverage files and a report in ./_coverage/index.html that looks like this:
The output was
rm -rf *.coverage
dune build --root . --instrument-with bisect_ppx
_build/default/bin/main.exe _build/default/plugin/plugin.cmxs
Plugin loaded successfully!
Hello from the plugin!
bisect-ppx-report html
As far as I can tell, coverage analysis is working for both the main program and the loaded plugin. What happens when you run the same commands?
Thank you! This time, I followed your instructions and succeeded—Bisect_ppx is working properly now. I must have made a mistake somewhere before, though I’m not exactly sure where—perhaps it was an issue with the working directory. Anyway, I’m really happy that I can now use Bisect_ppx to measure my project’s coverage. Thanks again!