-
Notifications
You must be signed in to change notification settings - Fork 697
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
cabal and integration tests or how to get code coverage for binaries #3902
Comments
See also #3682. They don't look the same but similar issues show up in the discussion. |
Okay, I got the manual hpc working again. Why did I get 100% (0/0) coverage? Turns out if I supply a random extra (positional) argument to Since all hpc errors are suppressed with this extra argument, my path's above are wrong. I only need to supply
Still, that I need the current version number does not really simplify automation. I think this can only be simplified if cabal would have explicit support for integration tests? |
The Cabal library for coverage tests really does need some love. I haven't fully investigated your report, but it definitely sounds plausible; would you be interested in helping contribute some patches to make this do the right thing? (We'll give you commit access!) |
Totally. But that's more like, I can try. Don't know if I can match up to the cabal code base. Probably, this need some conceptual work first. Maybe one could say that I am talking about integration tests, while cabal only supports unit tests. Right now I think it would be good to introduce another I think there is little input that we can get from other build systems since they have even less features. I will try to investigate a bit nevertheless. |
@qua-bla Yeah. To start off, what would a hypothetical manual section explaining how to do coverage look like? The current support is very specialized: http://cabal.readthedocs.io/en/latest/installing-packages.html?highlight=coverage#cmdoption-setup-configure--enable-coverage ; basically it is something like, "If you pass I think |
@sophie-h can you provide some more details about how you got coverage working for binaries? I have the same setup as you do:
when using @ezyang I can give a try improving the current state of affairs, starting with docs (#4401). Can you give me some hints, places in the code to look at, briefly explain how the internal cabal+hpc machinery works, etc ? |
@atodorov Sorry about the late reply, we would definitely be happy for contributions. There are two primary components to hpc in Cabal (library). First is building the program with hpc support. This is handled in Second is actually running the program and generating the coverage report. As coverage is currently only supported in test and bench, it is not surprising that this code is invoked from Let me know if you have other questions. |
My project structure:
The integration tests call the binary. To get code coverage for those calls, I tried to call pytest via
system
from an extra cabal test-suite. Turns out that this doesen't help. Also wrapping the binary into the test-suite (details) does not help. Seems like only the call fromcabal test
counts into the coverage report.So I went back to calling the binary directly and generating reports via hpc manually. First problem: I need to add an obscure
--hpcdir
for the library (dist/hpc/dyn/mix/<bin>-<version>/<random stuff>/
). Second: I get 100% (0/0) coverage. So the library is not included in the report of the binary?This was all working when I didn't had the split into library/binary. Is it really impossible to build a binary+library with working coverage via cabal?
The text was updated successfully, but these errors were encountered: