-
Notifications
You must be signed in to change notification settings - Fork 842
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
--coverage flag for stack test
#222
Comments
Assigning to @mgsloan. |
Some problems I encountered in general with
Some problems that I believe I encountered and that might be useful to test whether Stack does right once this ticket is implemented: |
On the last one, I believe the requirement is "delete .mix and .tix files before running", is that correct? I'm not sure if there's anything we can do about the other two at the stack level, unless I'm reading those incorrectly. |
Regarding the GHC bug, we might choose to work around them, for example to warn the user that coverage only works with Regarding the bad error messages: The adversarial case appears (seems to appear, I haven't fully understood it yet) when you're running (generates the |
FYI: Encountered that message while implementing this. Removing the file before running the suite does the trick. |
Okay, implemented. The output is like this:
It seems that one has to do a clean build from scratch otherwise the hpc program will complain. It turns out that doing a build from scratch with profiling enabled is rather problematic, leading to weird linking errors. I'm trying to figure out why. |
Okay, so I tracked it down, here's the problem: Running
We're not sure why. Suspected Cabal library issue. The icky workaround, to re-generate an HPC report, is to run:
|
Possible solution would be using a newer version of the Cabal library ala #174. We can touch base tomorrow on how we could test this out. |
Passing to @mgsloan to finish implementation. |
While this could be hacked around at the cabal level, this is a ghc issue - incremental recompilation doesn't notice when a .mix file is out of date or missing. So, if you do a normal build, and then ask for One solution would be to use |
I also ran into an issue when getting coverage information for a multi-package project. Since all the packages are build with coverage, we get coverage data for all of them in the .tix files. This means that when generating the report, we need to provide We may want to make it an option to only record coverage info for some subset of the packages, but this default is quite nice. It means that you get coverage information across your packages, rather than for a single one. Fix here: ec043d1 |
Cabal files with multiple test suites are also problematic. I have an initial fix for calling However, that doesn't make it work for a test project: https://github.com/mgsloan/multi-test-suite - here's the output:
While it says it can't find Main, the file is certainly there. Opening up the |
That's a bit of a comment deluge, so, here's a summary of what's left:
|
So, the remaining issue is to solve the problem @chrisdone encountered, where sometimes One sensible approach would be to I noted that there isn't one of these What's an alternative? We can look for all the As far as I can tell, this is the only tenable option to get to a nice user experience. Other options: A) Have users B) Have |
Happily, it seems that using I've documented the main issue I know of here @chrisdone Can you please confirm that the current state of |
Can do. |
Confirmed that I can re-run Cleaning is rarer, but this bug may bite some people. At any rate, one can at least re-run |
@chrisdone Thanks for checking! Looks like this is a bug with the profiling support (see #608), rather than with test coverage. I've made it so that test coverage doesn't use profiling flags, which I think fixes this issue. Confirmed? I can't quite do your repro because I run into another funky issue: #614 |
I think if there are any more issues with --coverage, additional issues can be opened - closing this one. |
Code coverage is a useful feature of GHC - it is particularly useful to figure out how much of the project's code is being exercised by tests. GHC ships with the
hpc
command, which can generate summary reports about source coverage and boolean-control coverage, as well as annotated versions of the source code with highlights where code was not covered.The goal is to optionally obtain a coverage report every time the user says
stack test
, e.g. by adding a--coverage
flag to that command.The output of the
hpc
command is driven by*.tix
files, generated by the test suite as a byproduct of execution when it is compiled using the-fhpc
flag. So we have two choices:hpc
command-line line tool to generate reports that we store in some known location in the project directory.*.tix
file. In particular for source code annotations, it may be useful to have that integrated withfpview
.The text was updated successfully, but these errors were encountered: