Closed DanBurton closed 4 years ago
May be related to the usage of Template Haskell (?)
Bump? I think I am running into this as well. Happy to provide enough details to reproduce if it would be helpful. Like Dan, I have double-checked that as far as I can tell, neither #1008 nor #1411 are the culprit. I am also using Template Haskell (to generate some lenses), though that hardly seems remarkable.
I happened to be on stack 1.7.1 so I upgraded to the latest (1.9.3) to see if that would help; it didn't.
Bump. I'm running into this too. No Template Haskell involved this time.
Repro:
$ curl -sS https://codeload.github.com/idontgetoutmuch/random/tar.gz/38d38ab65767cee47ed44b0acb8f67e813771d89 | tar xvz
$ cd random-*; stack test --coverage
I've got the same problem on my project, so I tried with a stack template with same result :
stack new my-project rio
cd my-project
stack test --coverage
output :
Building all executables for `my-project' once. After a successful build of all of them, only specified executables will be rebuilt.
my-project> configure (lib + exe + test)
Configuring my-project-0.1.0.0...
my-project> build (lib + exe + test)
Preprocessing library for my-project-0.1.0.0..
Building library for my-project-0.1.0.0..
[1 of 5] Compiling Paths_my_project
[2 of 5] Compiling Types
[3 of 5] Compiling Import
[4 of 5] Compiling Run
[5 of 5] Compiling Util
Preprocessing executable 'my-project-exe' for my-project-0.1.0.0..
Building executable 'my-project-exe' for my-project-0.1.0.0..
[1 of 2] Compiling Paths_my_project
[2 of 2] Compiling Main
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/my-project-exe/my-project-exe ...
Preprocessing test suite 'my-project-test' for my-project-0.1.0.0..
Building test suite 'my-project-test' for my-project-0.1.0.0..
[1 of 3] Compiling Paths_my_project
[2 of 3] Compiling UtilSpec
[3 of 3] Compiling Main
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/my-project-test/my-project-test ...
my-project> copy/register
Installing library in /home/matth/my-project/.stack-work/install/x86_64-linux-tinfo6/0f77fd90bf35fd5f5cebea0aab764d6782b23623e315035c52e134c831e3f74a/8.8.3/lib/x86_64-linux-ghc-8.8.3/my-project-0.1.0.0-EyzZPYII06LGJbZaNa3U4W
Installing executable my-project-exe in /home/matth/my-project/.stack-work/install/x86_64-linux-tinfo6/0f77fd90bf35fd5f5cebea0aab764d6782b23623e315035c52e134c831e3f74a/8.8.3/bin
Registering library for my-project-0.1.0.0..
my-project> test (suite: my-project-test)
Util
plus2
basic check
overflow
minus 2
+++ OK, passed 100 tests.
Finished in 0.0013 seconds
3 examples, 0 failures
my-project> Test suite my-project-test passed
Generating coverage report for my-project's test-suite "my-project-test"
Error: The coverage report for my-project's test-suite "my-project-test" did not consider any code. One possible cause
of this is if your test-suite builds the library code (see stack issue #1008). It may also indicate a bug in stack or the hpc program. Please report this issue if you think your coverage report should have meaningful results.
Completed 2 action(s).
Only one tix file found in /home/matth/my-project/.stack-work/install/x86_64-linux-tinfo6/0f77fd90bf35fd5f5cebea0aab764d6782b23623e315035c52e134c831e3f74a/8.8.3/hpc/, so not generating a unified coverage report.
An index of the generated HTML coverage reports is available at /home/matth/my-project/.stack-work/install/x86_64-linux-tinfo6/0f77fd90bf35fd5f5cebea0aab764d6782b23623e315035c52e134c831e3f74a/8.8.3/hpc/index.html
$ stack --version
Version 2.3.1, Git revision de2a7b694f07de7e6cf17f8c92338c16286b2878 (8103 commits) x86_64 hpack-0.33.0
Ok, I have been able to get it working :
run the same stack test --coverage
(will still fail) then
stack hpc report .
(from your project root)
:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:
^ stack hpc report .
works.
Interestingly, stack test --coverage
works on LTS 14.27, but not LTS 15.0. Probably a breakage in the upgraded GHC version (8.6 -> 8.8)?
:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:
Ok so running stack test --coverage -v
with LTS 14.27 vs LTS 15.0, I see LTS 14.27 including
--include aeson-schemas-1.2.0-KY8T02FjG98D5Nfn49pCZh:
and LTS 15.0 including
--include " aeson-schemas-1.2.0-JXw80ApJdoEEfjMvUrmUow:"
If I manually run the hpc report
command that stack is running, removing the whitespace from that include
option, it works.
So it seems like the culprit is extraReportArgs
in https://github.com/commercialhaskell/stack/blob/95aaf2bc2c969622679c2a8233e7bb637e43210d/src/Stack/Coverage.hs#L183
which it gets from eincludeName
in
https://github.com/commercialhaskell/stack/blob/95aaf2bc2c969622679c2a8233e7bb637e43210d/src/Stack/Coverage.hs#L138-L146
which it gets from findPackageFieldForBuiltPackage
in
https://github.com/commercialhaskell/stack/blob/95aaf2bc2c969622679c2a8233e7bb637e43210d/src/Stack/Coverage.hs#L128
andddddd the bug seems to be in extractField
https://github.com/commercialhaskell/stack/blob/95aaf2bc2c969622679c2a8233e7bb637e43210d/src/Stack/Coverage.hs#L434-L438
It seems like Cabal 3 formats the .conf
file now.
-- Cabal 2.4
name: aeson-schemas
version: 1.2.0
id: aeson-schemas-1.2.0-KY8T02FjG98D5Nfn49pCZh
key: aeson-schemas-1.2.0-KY8T02FjG98D5Nfn49pCZh
-- Cabal 3
name: aeson-schemas
version: 1.2.0
visibility: public
id: aeson-schemas-1.2.0-JXw80ApJdoEEfjMvUrmUow
key: aeson-schemas-1.2.0-JXw80ApJdoEEfjMvUrmUow
I'll make a PR for this
Steps to reproduce
Expected
I expect an accurate coverage report to be generated.
Actual
Note that:
hs-source-dirs: src
, while the test-suite target hashs-source-dirs: test
. The test suitebuild-depends
on the lib. (thus avoiding #1008)stack unpack
, with no previous.stack-work
state in the directory. (thus avoiding #1411. Even so, I have tried the same command with--ghc-options -fforce-recomp
; same result.)Here's the verbose output:
Stack version
Method of installation
stack upgrade