-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Question: Does it work with dune's cram test? #411
Comments
People in discord gave me a demo |
Great, thanks @Kakadu and @mooreryan! I'm going to reopen this as an issue about improving Bisect's docs. |
Hi! Thank you for this issue, and linking the discord example, this helped me setup I struggled to make the GitHub action part work, so I'm pasting here what I currently arrived at. This took me a few tries! (The feedback loop when trying to debug a GitHub action is not convenient). Putting it here if you want to discuss further, or perhaps help somebody else with that part. The part I struggled with I think was that I was afraid
This is taken from here. Thank you for the amazing bisect_ppx! |
The |
The main issue here was just to add |
Hi @aantron, The impression I had was that you'd need to choose a location for the bisect files (1), remember to delete any stale file there ahead of running the tests (2), supply the env var while running the test with an absolute path that terminates with a basename prefix (3), and supply the containing directory name during I guess I found the mention of the env variable By the way, while setting this up, I remember wondering whether things could be more opinionated in order to simplify these 4 steps. I wouldn't mind opting in for a default that you'd find reasonable. Another (perhaps complementary, or orthogonal) proposal is to publish somewhere a reference GitHub action that can serve as common action that people can use directly (like Thanks for looking back at this issue. |
The issue with that is I don't think we can detect in Bisect that the user is running cram tests, at least not in a maintainable way. I'll probably opt to document all of this in |
Also, Bisect_ppx itself uses cram tests, and Bisect's own |
I'm unsure about the details, but I have a vague recollection that using the |
^ Regarding getting it to work with cram tests? For that you need to ensure that you turn instrumentation on for the executable under test (in addition to the lib) and it will "just work". I only used the |
I've noticed similar issues reported in #418 and #432, which I believe might be In my experience, when running tests instrumented with ~/dev/catch-the-bunny$ dune clean
~/dev/catch-the-bunny$ dune runtest --instrument-with bisect_ppx
~/dev/catch-the-bunny$ bisect-ppx-report summary
Error: no *.coverage files found
Hint: is the code under test linked into the test suite?
Hint: did the tests run? However, if I set ~/dev/catch-the-bunny$ dune clean
~/dev/catch-the-bunny$ mkdir -p /tmp/coverage ; rm -rf /tmp/coverage/*
~/dev/catch-the-bunny$ BISECT_FILE=/tmp/coverage/data dune runtest --instrument-with bisect_ppx
~/dev/catch-the-bunny$ bisect-ppx-report summary --coverage-path /tmp/coverage
Coverage: 124/131 (94.66%) I suspect that I'm preparing to use Thank you! |
Here is why you need the BISECT_FILE env variable (at least with cram tests, ppx_inline_test, ppx_expect ...not sure if it will be the same for other testing frameworks): If you have a typical setup where the dune is running the tests in a sandbox, then the coverage files are disappearing because dune will delete the contents of the sandboxed directory when the tests are finished, and it won't promote the coverage files automatically. But it is still working (if you have instrumentation set up properly of course). To check that cov files are actually generated in your tests, you can add something like this to the end of a file containing inline or expect tests: let () = Sys.getcwd () |> Sys.readdir |> Array.iter (fun x -> print_endline x) To check that it is actually working in a cram test, stick this at the end of your cram file and you will see the generated coverage file:
If you set the |
Thank you, @mooreryan. Your response was enlightening! It has motivated me to delve deeper into bisect_ppx, and I've enabled it in several more repositories. I believe your explanation about the I have two more questions I'd appreciate your input on:
Thank you for your time and insights! |
I have a hunch about issue Edit: this was fixed by mbarbin/eio-rpc#4 |
Thanks @mbarbin and @mooreryan! I'm currently converting Luv to cram tests and will be applying Bisect_ppx to it afterwards, so I'll get some first-hand experience with this. I wasn't aware of any issues with ppx_inline_test or ppx_expect that would require |
If yes, could you please add some instructions to README?
The text was updated successfully, but these errors were encountered: