Skip to content

Commit

Permalink
HPC: Error out on multi-package when coverage is enabled (haskell#9493)
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Dec 4, 2023
1 parent 3d1ecb7 commit 0545169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cabal-install/src/Distribution/Client/CmdTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import Distribution.Client.Errors
import GHC.Environment
( getFullArgs
)
import Distribution.Client.ProjectConfig.Types (ProjectConfig(projectConfigLocalPackages))
import Distribution.Client.ProjectConfig (PackageConfig(packageConfigCoverage))

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

-- Multi package coverage is not supported (see cabal#9493)
when (length (localPackages baseCtx) > 1 && fromFlagOrDefault False (packageConfigCoverage (projectConfigLocalPackages $ projectConfig baseCtx))) $
dieWithException verbosity MultiPackageCoverageUnsupported

targetSelectors <-
either (reportTargetSelectorProblems verbosity) return
=<< readTargetSelectors (localPackages baseCtx) (Just TestKind) targetStrings
Expand Down
5 changes: 5 additions & 0 deletions cabal-install/src/Distribution/Client/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ data CabalInstallException
| CorruptedIndexCache String
| UnusableIndexState RemoteRepo Timestamp Timestamp
| MissingPackageList RemoteRepo
| MultiPackageCoverageUnsupported
deriving (Show, Typeable)

exceptionCodeCabalInstall :: CabalInstallException -> Int
Expand Down Expand Up @@ -334,6 +335,7 @@ exceptionCodeCabalInstall e = case e of
CorruptedIndexCache{} -> 7158
UnusableIndexState{} -> 7159
MissingPackageList{} -> 7160
MultiPackageCoverageUnsupported -> 7161

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

instance Exception (VerboseException CabalInstallException) where
displayException :: VerboseException CabalInstallException -> [Char]
Expand Down

0 comments on commit 0545169

Please sign in to comment.