diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index a82c614f641..7fa79a584dc 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -1758,11 +1758,10 @@ getInstalledPackagesMonitorFiles verbosity comp packageDBs progdb platform = -- | Looks up the 'InstalledPackageInfo' of a given 'UnitId' from the -- 'PackageDBStack' in the 'LocalBuildInfo'. getInstalledPackageById :: Verbosity -> LocalBuildInfo -> UnitId -> IO (Maybe InstalledPackageInfo) -getInstalledPackageById verbosity LocalBuildInfo{compiler,withPackageDB,withPrograms} unitid = do +getInstalledPackageById verbosity LocalBuildInfo{compiler, withPackageDB, withPrograms} unitid = do ipindex <- getInstalledPackages verbosity compiler withPackageDB withPrograms return $ lookupUnitId ipindex unitid - -- | The user interface specifies the package dbs to use with a combination of -- @--global@, @--user@ and @--package-db=global|user|clear|$file@. -- This function combines the global/user flag and interprets the package-db diff --git a/Cabal/src/Distribution/Simple/Hpc.hs b/Cabal/src/Distribution/Simple/Hpc.hs index a025fc95403..485c999727a 100644 --- a/Cabal/src/Distribution/Simple/Hpc.hs +++ b/Cabal/src/Distribution/Simple/Hpc.hs @@ -28,7 +28,7 @@ module Distribution.Simple.Hpc import Distribution.Compat.Prelude import Prelude () -import Distribution.ModuleName (main, ModuleName) +import Distribution.ModuleName (ModuleName, main) import Distribution.PackageDescription ( TestSuite (..) , testModules diff --git a/Cabal/src/Distribution/Simple/Setup/Config.hs b/Cabal/src/Distribution/Simple/Setup/Config.hs index cf3e400890c..30267bbfd76 100644 --- a/Cabal/src/Distribution/Simple/Setup/Config.hs +++ b/Cabal/src/Distribution/Simple/Setup/Config.hs @@ -836,21 +836,21 @@ configureOptions showOrParseArgs = (\v flags -> flags{configAllowDependingOnPrivateLibs = v}) trueArg , option - "" - ["coverage-for"] - "Module of a project-local library to include in the HPC report" - configCoverageFor - ( \v flags -> - flags - { configCoverageFor = - mergeListFlag (configCoverageFor flags) v - } - ) - ( reqArg' - "MODULE" - (Flag . (: []) . fromString) - (fmap prettyShow . fromFlagOrDefault []) - ) + "" + ["coverage-for"] + "Module of a project-local library to include in the HPC report" + configCoverageFor + ( \v flags -> + flags + { configCoverageFor = + mergeListFlag (configCoverageFor flags) v + } + ) + ( reqArg' + "MODULE" + (Flag . (: []) . fromString) + (fmap prettyShow . fromFlagOrDefault []) + ) ] where liftInstallDirs = diff --git a/Cabal/src/Distribution/Simple/Test.hs b/Cabal/src/Distribution/Simple/Test.hs index 3c96648a3ed..235838331f9 100644 --- a/Cabal/src/Distribution/Simple/Test.hs +++ b/Cabal/src/Distribution/Simple/Test.hs @@ -1,6 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ViewPatterns #-} ----------------------------------------------------------------------------- @@ -41,7 +41,14 @@ import Distribution.TestSuite import qualified Distribution.Types.LocalBuildInfo as LBI import Distribution.Types.UnqualComponentName +import Distribution.Simple.Configure (getInstalledPackageById) import Distribution.Simple.Errors +import Distribution.Simple.Setup (fromFlagOrDefault) +import Distribution.Simple.Setup.Common (extraCompilationArtifacts) +import Distribution.Simple.Setup.Config +import Distribution.Types.ExposedModule +import Distribution.Types.InstalledPackageInfo (InstalledPackageInfo (libraryDirs), exposedModules) +import Distribution.Types.LocalBuildInfo (LocalBuildInfo (..)) import System.Directory ( createDirectoryIfMissing , doesFileExist @@ -49,13 +56,6 @@ import System.Directory , removeFile ) import System.FilePath (()) -import Distribution.Simple.Setup.Config -import Distribution.Types.LocalBuildInfo (LocalBuildInfo(..)) -import Distribution.Simple.Configure (getInstalledPackageById) -import Distribution.Simple.Setup (fromFlagOrDefault) -import Distribution.Types.InstalledPackageInfo (InstalledPackageInfo(libraryDirs), exposedModules) -import Distribution.Types.ExposedModule -import Distribution.Simple.Setup.Common (extraCompilationArtifacts) -- | Perform the \"@.\/setup test@\" action. test @@ -79,9 +79,9 @@ test args pkg_descr lbi flags = do doTest :: [FilePath] - -- ^ The paths to the library components to include in the coverage report + -- \^ The paths to the library components to include in the coverage report -> [ModuleName] - -- ^ The modules to include in the coverage report + -- \^ The modules to include in the coverage report -> ( (PD.TestSuite, LBI.ComponentLocalBuildInfo) , Maybe TestSuiteLog ) @@ -144,27 +144,39 @@ test args pkg_descr lbi flags = do -- library by querying the package database keyed by unit-id: let coverageFor = fromFlagOrDefault [] (configCoverageFor (configFlags lbi)) ipkginfos <- catMaybes <$> mapM (getInstalledPackageById verbosity lbi) coverageFor - let ( concat -> testCoverageDistPrefs0, - concat -> testCoverageLibsModules ) = - -- ROMES:TODO: Is it right to use libraryDirs here? When do we have - -- more than one library dir for an installed package? - unzip $ map ( \ip -> ( map ( extraCompilationArtifacts) $ libraryDirs ip - , map exposedName $ exposedModules ip ) - ) ipkginfos + let ( concat -> testCoverageDistPrefs0 + , concat -> testCoverageLibsModules + ) = + -- ROMES:TODO: Is it right to use libraryDirs here? When do we have + -- more than one library dir for an installed package? + unzip $ + map + ( \ip -> + ( map ( extraCompilationArtifacts) $ libraryDirs ip + , map exposedName $ exposedModules ip + ) + ) + ipkginfos -- Additionally, we find the path to the testsuites' hpc build artifacts suitesInstalledInfo <- - catMaybes <$> - mapM ( getInstalledPackageById verbosity lbi - . LBI.componentUnitId - . snd . fst ) testsToRun + catMaybes + <$> mapM + ( getInstalledPackageById verbosity lbi + . LBI.componentUnitId + . snd + . fst + ) + testsToRun let testCoverageDistPrefs = testCoverageDistPrefs0 ++ ( concat - . map ( map ( extraCompilationArtifacts) - . libraryDirs - ) - $ suitesInstalledInfo ) + . map + ( map ( extraCompilationArtifacts) + . libraryDirs + ) + $ suitesInstalledInfo + ) let totalSuites = length testsToRun notice verbosity $ "Running " ++ show totalSuites ++ " test suites..." diff --git a/Cabal/src/Distribution/Simple/Test/ExeV10.hs b/Cabal/src/Distribution/Simple/Test/ExeV10.hs index 6931a3601cc..cde232588ed 100644 --- a/Cabal/src/Distribution/Simple/Test/ExeV10.hs +++ b/Cabal/src/Distribution/Simple/Test/ExeV10.hs @@ -8,8 +8,8 @@ module Distribution.Simple.Test.ExeV10 import Distribution.Compat.Prelude import Prelude () -import Distribution.ModuleName import Distribution.Compat.Environment +import Distribution.ModuleName import qualified Distribution.PackageDescription as PD import Distribution.Simple.Build.PathsModule import Distribution.Simple.BuildPaths diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 77a3852480a..f6346655c4d 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -21,7 +21,7 @@ module Distribution.Client.ProjectPlanning , BuildStyle (..) , CabalFileText - -- * Producing the elaborated install plan + -- * Producing the elaborated install plan , rebuildProjectConfig , rebuildInstallPlan @@ -4649,19 +4649,21 @@ inplaceBinRoot layout config package = -- The list of non-pre-existing libraries without module holes, i.e. the -- main library and sub-libraries components of all the local packages in -- the project that do not require instantiations or are instantiations. -determineCoverageFor :: PackageId - -- ^ The 'PackageId' of the package or component being configured - -> ElaboratedInstallPlan - -> Flag [UnitId] -determineCoverageFor configuredPkgSourceId plan = Flag $ - mapMaybe - ( \case - InstallPlan.Installed elab - | shouldCoverPkg elab -> Just $ elabUnitId elab - InstallPlan.Configured elab - | shouldCoverPkg elab -> Just $ elabUnitId elab - _ -> Nothing - ) +determineCoverageFor + :: PackageId + -- ^ The 'PackageId' of the package or component being configured + -> ElaboratedInstallPlan + -> Flag [UnitId] +determineCoverageFor configuredPkgSourceId plan = + Flag + $ mapMaybe + ( \case + InstallPlan.Installed elab + | shouldCoverPkg elab -> Just $ elabUnitId elab + InstallPlan.Configured elab + | shouldCoverPkg elab -> Just $ elabUnitId elab + _ -> Nothing + ) $ Graph.toList $ InstallPlan.toGraph plan where @@ -4674,4 +4676,3 @@ determineCoverageFor configuredPkgSourceId plan = Flag $ isIndefiniteOrInstantiation :: ModuleShape -> Bool isIndefiniteOrInstantiation = not . Set.null . modShapeRequires -