Skip to content

Commit

Permalink
FOURMOLU
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Dec 6, 2023
1 parent 5e3033a commit 3e78b94
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 61 deletions.
3 changes: 1 addition & 2 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Hpc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions Cabal/src/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
62 changes: 37 additions & 25 deletions Cabal/src/Distribution/Simple/Test.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ViewPatterns #-}

-----------------------------------------------------------------------------

Expand Down Expand Up @@ -41,21 +41,21 @@ 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
, getDirectoryContents
, 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
Expand All @@ -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
)
Expand Down Expand Up @@ -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..."
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Test/ExeV10.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ unpackPackageTarball verbosity tarball parentdir pkgid pkgTextOverride =
parentdir
</> pkgsubdir
</> prettyShow pkgname
<.> "cabal"
<.> "cabal"
pkgsubdir = prettyShow pkgid
pkgname = packageName pkgid

Expand Down
33 changes: 17 additions & 16 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Distribution.Client.ProjectPlanning
, BuildStyle (..)
, CabalFileText

-- * Producing the elaborated install plan
-- * Producing the elaborated install plan
, rebuildProjectConfig
, rebuildInstallPlan

Expand Down Expand Up @@ -1725,7 +1725,7 @@ elaborateInstallPlan
dieProgress $
text "Internal libraries only supported with per-component builds."
$$ text "Per-component builds were disabled because"
<+> fsep (punctuate comma reasons)
<+> fsep (punctuate comma reasons)
-- TODO: Maybe exclude Backpack too

elab0 = elaborateSolverToCommon spkg
Expand Down Expand Up @@ -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
Expand All @@ -4674,4 +4676,3 @@ determineCoverageFor configuredPkgSourceId plan = Flag $

isIndefiniteOrInstantiation :: ModuleShape -> Bool
isIndefiniteOrInstantiation = not . Set.null . modShapeRequires

0 comments on commit 3e78b94

Please sign in to comment.