The problem manifests itself with errors like the following when running the testsuite.
> touch tests/PackageTests/TestStanza/Setup.hs # to reproduce the issue reliably
> cabal test
ERROR: user error (Command "[...]/tests/PackageTests/TestStanza/Setup clean"
in PackageTests/TestStanza failed.)
The unit-tests testsuite is compiled and run with HPC support enabled. Internally, it compiles various Setup.hs files, also with HPC enabled. Each of these Setup executables has its own Main module. However, when run, they all collect coverage information in the same file -- dist/hpc/tix/unit-tests/unit-tests.tix (This file name is determined by the HPCTIXFILE environment variable, which is set by Cabal's testsuite support). HPC finds the clashing module name and bails out.
(I will submit a fix shortly)
6ed73cd is a minimal fix for this issue.
If we actually want hpc support for these Setup executables, I believe we should ask for proper package support in HPC first: instead of identifying a module simply by its name, include the package name into the key as well. Then we could compile each Setup executable in its own package using -package-name.
@dcoutts Maybe you can comment on this, since we already discussed it on #haskell?
Build Setup executables without HPC. Fixes #1012.