Repository navigation
Description
Describe the bug
In #9464, we lifted the restrictions that made cabal unable to support enable multi-component coverage and further unblocked support for coverage of multi-package projects. However, due to a limitation of HPC, we introduced a deliberate exception which aborts cabal test --enable-coverage for multi package projects.
Currently, HPC records in .mix files the relative path to the source file containing the module corresponding to the .mix file.
However, this path being relative makes the hpc markup command invoked from the root of the project (rather than the package) after running the testsuite fail because the source of the module cannot be found using the relative path.
An undesireable "fix" would be to add --srcdir for each package in the project to the markup invocation, however, that is not a great idea because:
markupis invoked by Cabal the library, which should not know about the multiple packages in a project- if two packages export the same module, there will be conflicts in the HPC invocation
Ideally, HPC would record the full path to a module's source or the source of the module could be recorded in the .mix file.
To fix this ticket, HPC must better handle paths to source directories and then it should suffice to delete the check for multi-packages when --enable-coverage is on (the error thrown is named MultiPackageCoverageUnsupported). It may also be useful to grep for this ticket number in the source.
To Reproduce
There is a test which is expected to fail in a .test.hs file PackageTests/MultipleLibraries/Successful which enables coverage for the project.
If this is fixed, the coverage report for that test should be successfully generated.
As an additional real-world example you may also try to run in the root of the cabal project run
cabal test --enable-coverage cabal-install
Activity
Per-component multi-package builds with coverage enabled
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
Per-component multi-package builds with coverage enabled
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
Per-component multi-package builds with coverage enabled
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
mpickering commentedon Dec 4, 2023
cc @BinderDavid
BinderDavid commentedon Dec 4, 2023
Thanks for the ping. I will take a look :) I am a bit busy during this week, but I can take a closer look on the weekend.
Per-component multi-package builds with coverage enabled
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
Per-component multi-package builds with coverage enabled
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
Per-component multi-package builds with coverage enabled
25 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
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