You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cabal new-test doesn't work with library-coverage for components with other-modules #5213
$ cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.1.0 of the Cabal library
I'll work on preparing a minimal example in a bit. In the meantime, you can trigger this issue with scotty-0.11.0:
$ cabal get scotty-0.11.0
Unpacking to scotty-0.11.0/
$ cd scotty-0.11.0/
$ cat > cabal.project << EOF
> packages: .
> package scotty
> library-coverage: true
> EOF
$ cabal new-test
Resolving dependencies...
In order, the following will be built (use -v for more details):
- scotty-0.11.0 (lib) (first run)
- scotty-0.11.0 (test:spec) (first run)
Configuring library for scotty-0.11.0..
Preprocessing library for scotty-0.11.0..
Building library for scotty-0.11.0..
<build output elided>
Configuring test suite 'spec' for scotty-0.11.0..
Preprocessing test suite 'spec' for scotty-0.11.0..
Building test suite 'spec' for scotty-0.11.0..
<build output elided>
Running 1 test suites...
Test suite spec: RUNNING...
<test output elided>
Test suite spec: PASS
Test suite logged to:
/home/ryanglscott/Documents/Hacking/Haskell/scotty-0.11.0/dist-newstyle/build/x86_64-linux/ghc-8.2.2/scotty-0.11.0/c/spec/test/scotty-0.11.0-spec.log
hpc: can not find scotty-0.11.0-inplace/Web.Scotty.Util in ./.hpc, /home/ryanglscott/Documents/Hacking/Haskell/scotty-0.11.0/dist-newstyle/build/x86_64-linux/ghc-8.2.2/scotty-0.11.0/c/spec/hpc/vanilla/mix/scotty-0.11.0, /home/ryanglscott/Documents/Hacking/Haskell/scotty-0.11.0/dist-newstyle/build/x86_64-linux/ghc-8.2.2/scotty-0.11.0/c/spec/hpc/vanilla/mix/spec
CallStack (from HasCallStack):
error, called at libraries/hpc/Trace/Hpc/Mix.hs:122:15 in hpc-0.6.0.3:Trace.Hpc.Mix
cabal: Tests failed for test:spec from scotty-0.11.0.
This error doesn't happen for another project, wai-middleware-static-0.8.1. Unlike scotty, wai-middleware-static has no other-modules, so I suspect that is the culprit here.
$ git clone https://github.com/RyanGlScott/cabal-gh5213
Cloning into 'cabal-gh5213'...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 16 (delta 1), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
$ cd cabal-gh5213/
$ cabal new-test
Resolving dependencies...
In order, the following will be built (use -v for more details):
- cabal-gh5213-0.1 (lib) (first run)
- cabal-gh5213-0.1 (test:tests) (first run)
Configuring library for cabal-gh5213-0.1..
Preprocessing library for cabal-gh5213-0.1..
Building library for cabal-gh5213-0.1..
[1 of 2] Compiling CabalGH5213Other ( src/CabalGH5213Other.hs, /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/build/CabalGH5213Other.o )
[2 of 2] Compiling CabalGH5213Exposed ( src/CabalGH5213Exposed.hs, /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/build/CabalGH5213Exposed.o )
Configuring test suite 'tests' for cabal-gh5213-0.1..
Preprocessing test suite 'tests' for cabal-gh5213-0.1..
Building test suite 'tests' for cabal-gh5213-0.1..
[1 of 1] Compiling Main ( tests/Main.hs, /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/build/tests/tests-tmp/Main.o )
Linking /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/build/tests/tests ...
Running 1 test suites...
Test suite tests: RUNNING...
42
Test suite tests: PASS
Test suite logged to:
/home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/test/cabal-gh5213-0.1-tests.log
hpc: can not find cabal-gh5213-0.1-inplace/CabalGH5213Other in ./.hpc, /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/hpc/vanilla/mix/cabal-gh5213-0.1, /home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/hpc/vanilla/mix/tests
CallStack (from HasCallStack):
error, called at libraries/hpc/Trace/Hpc/Mix.hs:122:15 in hpc-0.6.0.3:Trace.Hpc.Mix
cabal: Tests failed for test:tests from cabal-gh5213-0.1.
I'm not sure why hpc can't find it, though, especially since it's passed '--hpcdir=/home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/hpc/vanilla/mix/cabal-gh5213-0.1'.
I quick strace reveals, that hpc is looking at e.g.
open("./.hpc/cabal-gh5213-0.1-inplace/CabalGH5213Other.mix", O_RDONLY|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
open("./dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/t/tests/hpc/vanilla/mix/cabal-gh5213-0.1/cabal-gh5213-0.1-inplace/CabalGH5213Other.mix", O_RDONLY|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
open("./dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/t/tests/hpc/vanilla/mix/tests/cabal-gh5213-0.1-inplace/CabalGH5213Other.mix", O_RDONLY|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
I forgot to tackle this in time for 2.4, but I'll try to get to this within the next 1-2 weeks; but it's probably not going to be ready in time for the cabal-install 2.4.0.0 rls; more like 2.4.1.0
a related problem folks with fancy code setups hit is when they try to do coverage and have local/not hackage deps, and naively cabal tries do enable coverage on the local package. the work around for now is to set --disable-coverage for that local dep in the cabal.project file. But i think thats an issue that might be related. but probably merits its own ticket
5:53 PM <davean> ocharles: you can specificly disable coverage on the other parts of the project and it will work
5:54 PM <davean> package reflex-time
5:54 PM <davean> coverage: False
5:54 PM <davean> library-coverage: False
5:54 PM <davean> as an example
5:55 PM <davean> It should, of course, work to have coverage for all of them
5:55 PM <davean> it just doesn't
a near term improvment would be ANY sort of warning saying "this is a known issue, heres what you need to do "
Activity
RyanGlScott commentedon Mar 14, 2018
A minimal reproducer can be found at https://github.com/RyanGlScott/cabal-gh5213:
RyanGlScott commentedon Mar 14, 2018
-v3revealed that this is howhpcis being invoked:It's worth noting that
CabalGH5213Other.mixis being created:I'm not sure why
hpccan't find it, though, especially since it's passed'--hpcdir=/home/ryanglscott/Documents/Hacking/Haskell/cabal-gh5213/dist-newstyle/build/x86_64-linux/ghc-8.2.2/cabal-gh5213-0.1/c/tests/hpc/vanilla/mix/cabal-gh5213-0.1'.hvr commentedon Mar 14, 2018
I quick
stracereveals, thathpcis looking at e.g.whereas it should have been looking at
for reference, the flags in my case were:
So it appears that cabal is not passing the right
--hpcdirtohpc......or rather, that the.mixfile isn't created in the right folder; the folder passed as--hpcdiris the proper one.We're indeed missing the
--hpcdirpointing to the library component's.mixfiles!In other words, the
erroneously pointing into the test-components build-dir, should instead have been
pointing to the library component's build-dir.
The more I investigate, the more issues/tech-debt I notice... :-/
hvr commentedon Sep 5, 2018
I forgot to tackle this in time for 2.4, but I'll try to get to this within the next 1-2 weeks; but it's probably not going to be ready in time for the cabal-install 2.4.0.0 rls; more like 2.4.1.0
vu3rdd commentedon Sep 5, 2018
Thanks @hvr.
erikd commentedon Feb 5, 2019
Just hit this myself with cabal 2.4.1.0. Is that expected?
23Skidoo commentedon Feb 5, 2019
"Expected" in the sense that it's a known issue, yes.
cartazio commentedon May 3, 2019
#4798 is related right?
cartazio commentedon May 4, 2019
a related problem folks with fancy code setups hit is when they try to do coverage and have local/not hackage deps, and naively cabal tries do enable coverage on the local package. the work around for now is to set --disable-coverage for that local dep in the cabal.project file. But i think thats an issue that might be related. but probably merits its own ticket
cartazio commentedon Feb 14, 2020
quoting @davean
a near term improvment would be ANY sort of warning saying "this is a known issue, heres what you need to do "
65 remaining items
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db
Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db
HPC artifacts are written and read from pkg-db
Per-component multi-package builds with coverage enabled
HPC artifacts are written and read from pkg-db