diff --git a/Cabal/src/Distribution/Simple/Flag.hs b/Cabal/src/Distribution/Simple/Flag.hs index e9e444457e6..f8598697028 100644 --- a/Cabal/src/Distribution/Simple/Flag.hs +++ b/Cabal/src/Distribution/Simple/Flag.hs @@ -149,7 +149,6 @@ mergeListFlag :: Flag [a] -> Flag [a] -> Flag [a] mergeListFlag currentFlags v = Flag $ concat (flagToList currentFlags ++ flagToList v) - -- | Types that represent boolean flags. class BooleanFlag a where asBool :: a -> Bool diff --git a/Cabal/src/Distribution/Simple/Hpc.hs b/Cabal/src/Distribution/Simple/Hpc.hs index 464bf01a2ad..e39b75d4ae4 100644 --- a/Cabal/src/Distribution/Simple/Hpc.hs +++ b/Cabal/src/Distribution/Simple/Hpc.hs @@ -1,6 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE RankNTypes #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RankNTypes #-} ----------------------------------------------------------------------------- @@ -35,20 +35,20 @@ import Distribution.PackageDescription ) import qualified Distribution.PackageDescription as PD import Distribution.Pretty +import Distribution.Simple.Flag (fromFlagOrDefault) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo (..)) import Distribution.Simple.Program ( hpcProgram , requireProgramVersion ) import Distribution.Simple.Program.Hpc (markup, union) +import Distribution.Simple.Setup (TestFlags (..)) import Distribution.Simple.Utils (notice) import Distribution.Types.UnqualComponentName import Distribution.Verbosity (Verbosity ()) import Distribution.Version (anyVersion) import System.Directory (createDirectoryIfMissing, doesFileExist) import System.FilePath -import Distribution.Simple.Setup (TestFlags(..)) -import Distribution.Simple.Flag (fromFlagOrDefault) -- ------------------------------------------------------------------------- -- Haskell Program Coverage @@ -152,14 +152,14 @@ markupPackage verbosity TestFlags{testCoverageDistPrefs, testCoverageLibsModules tixFilePath testDistPref way testName' -- And call 'markupPackage' once per `test` invocation with all the -- testsuites to run, which results in multiple tix files being considered - _ -> do + _ -> do let excluded = concatMap testModules suites ++ [main] pkgName = prettyShow $ PD.package pkg_descr summedTixFile = tixFilePath testDistPref way pkgName createDirectoryIfMissing True $ takeDirectory summedTixFile union hpc verbosity tixFiles summedTixFile excluded return summedTixFile - + markup hpc hpcVer verbosity tixFile mixDirs htmlDir' included notice verbosity $ "Package coverage report written to " @@ -170,4 +170,3 @@ markupPackage verbosity TestFlags{testCoverageDistPrefs, testCoverageLibsModules testNames = fmap (unUnqualComponentName . testName) suites mixDirs = map (`mixDir` way) (fromFlagOrDefault [] testCoverageDistPrefs) included = fromFlagOrDefault [] testCoverageLibsModules - diff --git a/Cabal/src/Distribution/Simple/Setup/Test.hs b/Cabal/src/Distribution/Simple/Setup/Test.hs index 0e5373f1b81..c2fa3f14d6d 100644 --- a/Cabal/src/Distribution/Simple/Setup/Test.hs +++ b/Cabal/src/Distribution/Simple/Setup/Test.hs @@ -40,8 +40,8 @@ import Distribution.Simple.Utils import Distribution.Verbosity import qualified Text.PrettyPrint as Disp -import Distribution.Simple.Setup.Common import Distribution.ModuleName (ModuleName) +import Distribution.Simple.Setup.Common -- ------------------------------------------------------------ @@ -98,7 +98,6 @@ data TestFlags = TestFlags -- excludes indefinite libraries and instantiations because HPC does not -- support backpack - Nov. 2023). Cabal uses these paths as dist prefixes to -- determine the path to the `mix` dirs of each component to cover. - , -- TODO: think about if/how options are passed to test exes testOptions :: [PathTemplate] } @@ -223,35 +222,37 @@ testOptions' showOrParseArgs = (\v flags -> flags{testFailWhenNoTestSuites = v}) trueArg , option - [] - ["coverage-module"] - "Module of a project-local library to include in the HPC report" - testCoverageLibsModules - (\v flags -> - flags{ testCoverageLibsModules = - mergeListFlag (testCoverageLibsModules flags) v - } - ) - ( reqArg' - "MODULE" - (Flag . (: []) . fromString) - (fmap prettyShow . fromFlagOrDefault []) - ) + [] + ["coverage-module"] + "Module of a project-local library to include in the HPC report" + testCoverageLibsModules + ( \v flags -> + flags + { testCoverageLibsModules = + mergeListFlag (testCoverageLibsModules flags) v + } + ) + ( reqArg' + "MODULE" + (Flag . (: []) . fromString) + (fmap prettyShow . fromFlagOrDefault []) + ) , option - [] - ["coverage-dist-dir"] - "The directory where Cabal puts generated build files of an HPC enabled component" - testCoverageDistPrefs - (\v flags -> - flags{ testCoverageDistPrefs = - mergeListFlag (testCoverageDistPrefs flags) v - } - ) - ( reqArg' - "DIR" - (Flag . (: [])) - (fromFlagOrDefault []) - ) + [] + ["coverage-dist-dir"] + "The directory where Cabal puts generated build files of an HPC enabled component" + testCoverageDistPrefs + ( \v flags -> + flags + { testCoverageDistPrefs = + mergeListFlag (testCoverageDistPrefs flags) v + } + ) + ( reqArg' + "DIR" + (Flag . (: [])) + (fromFlagOrDefault []) + ) , option [] ["test-options"] diff --git a/cabal-install/src/Distribution/Client/CmdTest.hs b/cabal-install/src/Distribution/Client/CmdTest.hs index fff56d3b80d..60731c8d3f1 100644 --- a/cabal-install/src/Distribution/Client/CmdTest.hs +++ b/cabal-install/src/Distribution/Client/CmdTest.hs @@ -66,11 +66,11 @@ import Distribution.Verbosity import qualified System.Exit (exitSuccess) import Distribution.Client.Errors +import Distribution.Client.ProjectConfig (PackageConfig (packageConfigCoverage)) +import Distribution.Client.ProjectConfig.Types (ProjectConfig (projectConfigLocalPackages)) import GHC.Environment ( getFullArgs ) -import Distribution.Client.ProjectConfig.Types (ProjectConfig(projectConfigLocalPackages)) -import Distribution.Client.ProjectConfig (PackageConfig(packageConfigCoverage)) testCommand :: CommandUI (NixStyleFlags ()) testCommand = diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index 1b00113d8e7..9d208e121e8 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -1099,7 +1099,7 @@ unpackPackageTarball verbosity tarball parentdir pkgid pkgTextOverride = parentdir pkgsubdir prettyShow pkgname - <.> "cabal" + <.> "cabal" pkgsubdir = prettyShow pkgid pkgname = packageName pkgid diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 31994b90d9e..08bb3f389b2 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -7,7 +7,8 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE NoMonoLocalBinds #-} -- MUST come after TypeFamilies because TypeFamilies imply MonoLocalBinds +-- MUST come after TypeFamilies because TypeFamilies imply MonoLocalBinds +{-# LANGUAGE NoMonoLocalBinds #-} -- | Planning how to build everything in a project. module Distribution.Client.ProjectPlanning @@ -148,10 +149,11 @@ import Distribution.Simple.Program.Db import Distribution.Simple.Program.Find import Distribution.Simple.Setup ( Flag (..) + , TestFlags (testCoverageDistPrefs) , flagToList , flagToMaybe , fromFlagOrDefault - , toFlag, TestFlags (testCoverageDistPrefs) + , toFlag ) import qualified Distribution.Simple.Setup as Cabal import Distribution.System @@ -1724,7 +1726,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 @@ -4306,7 +4308,7 @@ setupHsTestFlags plan (ElaboratedConfiguredPackage{..}) sharedConfig verbosity d covLibsDistPref = map (distBuildDirectory distDirLayout . elabDistDirParams sharedConfig) librariesToCover -- The list of modules from libraries to consider in hpc, that Cabal passes to the hpc markup call -- This list includes all modules, not only the exposed ones. - covIncludeModules = concatMap (\ElaboratedConfiguredPackage{elabModuleShape=modShape} -> Map.keys $ modShapeProvides modShape) librariesToCover + covIncludeModules = concatMap (\ElaboratedConfiguredPackage{elabModuleShape = modShape} -> Map.keys $ modShapeProvides modShape) librariesToCover -- 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 @@ -4316,18 +4318,21 @@ setupHsTestFlags plan (ElaboratedConfiguredPackage{..}) sharedConfig verbosity d -- this seemingly includes the packages that are not local to the project?! -- Weird, because we filter on localToProject! -- Try it on cabal-install: cabal test --enable-coverage cabal-install - librariesToCover - = mapMaybe (\case - InstallPlan.Installed elab@ElaboratedConfiguredPackage{elabModuleShape=modShape} + librariesToCover = + mapMaybe + ( \case + InstallPlan.Installed elab@ElaboratedConfiguredPackage{elabModuleShape = modShape} | elabLocalToProject - , not (isIndefiniteOrInstantiation modShape) - -> Just elab - InstallPlan.Configured elab@ElaboratedConfiguredPackage{elabModuleShape=modShape} + , not (isIndefiniteOrInstantiation modShape) -> + Just elab + InstallPlan.Configured elab@ElaboratedConfiguredPackage{elabModuleShape = modShape} | elabLocalToProject - , not (isIndefiniteOrInstantiation modShape) - -> Just elab + , not (isIndefiniteOrInstantiation modShape) -> + Just elab _ -> Nothing - ) $ Graph.toList $ InstallPlan.toGraph plan + ) + $ Graph.toList + $ InstallPlan.toGraph plan isIndefiniteOrInstantiation :: ModuleShape -> Bool isIndefiniteOrInstantiation = not . Set.null . modShapeRequires @@ -4465,7 +4470,6 @@ setupHsHaddockArgs :: ElaboratedConfiguredPackage -> [String] setupHsHaddockArgs elab = map (showComponentTarget (packageId elab)) (elabHaddockTargets elab) - ------------------------------------------------------------------------------ -- * Sharing installed packages