Skip to content

Commit d34b801

Browse files
committed
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
1 parent f9ed09f commit d34b801

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cabal-install/src/Distribution/Client/CmdTest.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ import Distribution.Client.Errors
6969
import GHC.Environment
7070
( getFullArgs
7171
)
72+
import Distribution.Client.ProjectConfig.Types (ProjectConfig(projectConfigLocalPackages))
73+
import Distribution.Client.ProjectConfig (PackageConfig(packageConfigCoverage))
7274

7375
testCommand :: CommandUI (NixStyleFlags ())
7476
testCommand =
@@ -125,6 +127,10 @@ testAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
125127
testAction flags@NixStyleFlags{..} targetStrings globalFlags = do
126128
baseCtx <- establishProjectBaseContext verbosity cliConfig OtherCommand
127129

130+
-- Multi package coverage is not supported (see cabal#9493)
131+
when (length (localPackages baseCtx) > 1 && fromFlagOrDefault False (packageConfigCoverage (projectConfigLocalPackages $ projectConfig baseCtx))) $
132+
dieWithException verbosity MultiPackageCoverageUnsupported
133+
128134
targetSelectors <-
129135
either (reportTargetSelectorProblems verbosity) return
130136
=<< readTargetSelectors (localPackages baseCtx) (Just TestKind) targetStrings

cabal-install/src/Distribution/Client/Errors.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ data CabalInstallException
184184
| CorruptedIndexCache String
185185
| UnusableIndexState RemoteRepo Timestamp Timestamp
186186
| MissingPackageList RemoteRepo
187+
| MultiPackageCoverageUnsupported
187188
deriving (Show, Typeable)
188189

189190
exceptionCodeCabalInstall :: CabalInstallException -> Int
@@ -334,6 +335,7 @@ exceptionCodeCabalInstall e = case e of
334335
CorruptedIndexCache{} -> 7158
335336
UnusableIndexState{} -> 7159
336337
MissingPackageList{} -> 7160
338+
MultiPackageCoverageUnsupported -> 7161
337339

338340
exceptionMessageCabalInstall :: CabalInstallException -> String
339341
exceptionMessageCabalInstall e = case e of
@@ -849,6 +851,9 @@ exceptionMessageCabalInstall e = case e of
849851
"The package list for '"
850852
++ unRepoName (remoteRepoName repoRemote)
851853
++ "' does not exist. Run 'cabal update' to download it."
854+
MultiPackageCoverageUnsupported ->
855+
"--enable-coverage was specified, but program coverage is not supported in "
856+
++ "multiple package projects because of a HPC limitation (see cabal#9493)."
852857

853858
instance Exception (VerboseException CabalInstallException) where
854859
displayException :: VerboseException CabalInstallException -> [Char]

0 commit comments

Comments
 (0)