Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does bisect_ppx work with dynamic libraries #443

Open
wanghuibin0 opened this issue Nov 23, 2024 · 4 comments
Open

Does bisect_ppx work with dynamic libraries #443

wanghuibin0 opened this issue Nov 23, 2024 · 4 comments

Comments

@wanghuibin0
Copy link

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?

@aantron
Copy link
Owner

aantron commented Nov 24, 2024

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?

@wanghuibin0
Copy link
Author

wanghuibin0 commented Nov 25, 2024

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

@aantron
Copy link
Owner

aantron commented Nov 25, 2024

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:

image

image

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?

@wanghuibin0
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants