Commit a9dc1996 authored by barmston's avatar barmston
Browse files

Add --enable-{tests,benchmarks} to freeze command

If they are present the dependencies of all test and benchmark stanzas are
included in the frozen set of dependencies.
parent 858ec908
...@@ -18,7 +18,7 @@ module Distribution.Client.Freeze ( ...@@ -18,7 +18,7 @@ module Distribution.Client.Freeze (
import Distribution.Client.Config ( SavedConfig(..) ) import Distribution.Client.Config ( SavedConfig(..) )
import Distribution.Client.Types import Distribution.Client.Types
import Distribution.Client.Targets import Distribution.Client.Targets
import Distribution.Client.Dependency hiding ( addConstraints ) import Distribution.Client.Dependency
import Distribution.Client.IndexUtils as IndexUtils import Distribution.Client.IndexUtils as IndexUtils
( getSourcePackages, getInstalledPackages ) ( getSourcePackages, getInstalledPackages )
import Distribution.Client.InstallPlan import Distribution.Client.InstallPlan
...@@ -41,7 +41,7 @@ import qualified Distribution.Client.PackageIndex as PackageIndex ...@@ -41,7 +41,7 @@ import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Simple.Program import Distribution.Simple.Program
( ProgramConfiguration ) ( ProgramConfiguration )
import Distribution.Simple.Setup import Distribution.Simple.Setup
( fromFlag ) ( fromFlag, fromFlagOrDefault )
import Distribution.Simple.Utils import Distribution.Simple.Utils
( die, notice, debug, writeFileAtomic ) ( die, notice, debug, writeFileAtomic )
import Distribution.System import Distribution.System
...@@ -156,12 +156,23 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags ...@@ -156,12 +156,23 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
. setShadowPkgs shadowPkgs . setShadowPkgs shadowPkgs
. addConstraints
[ PackageConstraintStanzas (pkgSpecifierTarget pkgSpecifier) stanzas
| pkgSpecifier <- pkgSpecifiers ]
. maybe id applySandboxInstallPolicy mSandboxPkgInfo . maybe id applySandboxInstallPolicy mSandboxPkgInfo
$ standardInstallPolicy installedPkgIndex sourcePkgDb pkgSpecifiers $ standardInstallPolicy installedPkgIndex sourcePkgDb pkgSpecifiers
logMsg message rest = debug verbosity message >> rest logMsg message rest = debug verbosity message >> rest
stanzas = concat
[ if testsEnabled then [TestStanzas] else []
, if benchmarksEnabled then [BenchStanzas] else []
]
testsEnabled = fromFlagOrDefault False $ freezeTests freezeFlags
benchmarksEnabled = fromFlagOrDefault False $ freezeBenchmarks freezeFlags
reorderGoals = fromFlag (freezeReorderGoals freezeFlags) reorderGoals = fromFlag (freezeReorderGoals freezeFlags)
independentGoals = fromFlag (freezeIndependentGoals freezeFlags) independentGoals = fromFlag (freezeIndependentGoals freezeFlags)
shadowPkgs = fromFlag (freezeShadowPkgs freezeFlags) shadowPkgs = fromFlag (freezeShadowPkgs freezeFlags)
...@@ -189,10 +200,11 @@ pruneInstallPlan installPlan pkgSpecifiers = ...@@ -189,10 +200,11 @@ pruneInstallPlan installPlan pkgSpecifiers =
freezePackages :: Package pkg => Verbosity -> [pkg] -> IO () freezePackages :: Package pkg => Verbosity -> [pkg] -> IO ()
freezePackages verbosity pkgs = do freezePackages verbosity pkgs = do
pkgEnv <- fmap (createPkgEnv . addConstraints) $ loadUserConfig verbosity "" pkgEnv <- fmap (createPkgEnv . addFrozenConstraints) $
loadUserConfig verbosity ""
writeFileAtomic userPackageEnvironmentFile $ showPkgEnv pkgEnv writeFileAtomic userPackageEnvironmentFile $ showPkgEnv pkgEnv
where where
addConstraints config = addFrozenConstraints config =
config { config {
savedConfigureExFlags = (savedConfigureExFlags config) { savedConfigureExFlags = (savedConfigureExFlags config) {
configExConstraints = constraints pkgs configExConstraints = constraints pkgs
......
...@@ -547,6 +547,8 @@ fetchCommand = CommandUI { ...@@ -547,6 +547,8 @@ fetchCommand = CommandUI {
data FreezeFlags = FreezeFlags { data FreezeFlags = FreezeFlags {
freezeDryRun :: Flag Bool, freezeDryRun :: Flag Bool,
freezeTests :: Flag Bool,
freezeBenchmarks :: Flag Bool,
freezeSolver :: Flag PreSolver, freezeSolver :: Flag PreSolver,
freezeMaxBackjumps :: Flag Int, freezeMaxBackjumps :: Flag Int,
freezeReorderGoals :: Flag Bool, freezeReorderGoals :: Flag Bool,
...@@ -558,6 +560,8 @@ data FreezeFlags = FreezeFlags { ...@@ -558,6 +560,8 @@ data FreezeFlags = FreezeFlags {
defaultFreezeFlags :: FreezeFlags defaultFreezeFlags :: FreezeFlags
defaultFreezeFlags = FreezeFlags { defaultFreezeFlags = FreezeFlags {
freezeDryRun = toFlag False, freezeDryRun = toFlag False,
freezeTests = toFlag False,
freezeBenchmarks = toFlag False,
freezeSolver = Flag defaultSolver, freezeSolver = Flag defaultSolver,
freezeMaxBackjumps = Flag defaultMaxBackjumps, freezeMaxBackjumps = Flag defaultMaxBackjumps,
freezeReorderGoals = Flag False, freezeReorderGoals = Flag False,
...@@ -581,6 +585,16 @@ freezeCommand = CommandUI { ...@@ -581,6 +585,16 @@ freezeCommand = CommandUI {
freezeDryRun (\v flags -> flags { freezeDryRun = v }) freezeDryRun (\v flags -> flags { freezeDryRun = v })
trueArg trueArg
, option [] ["tests"]
"freezing of the dependencies of any tests suites in the package description file."
freezeTests (\v flags -> flags { freezeTests = v })
(boolOpt [] [])
, option [] ["benchmarks"]
"freezing of the dependencies of any benchmarks suites in the package description file."
freezeBenchmarks (\v flags -> flags { freezeBenchmarks = v })
(boolOpt [] [])
] ++ ] ++
optionSolver freezeSolver (\v flags -> flags { freezeSolver = v }) : optionSolver freezeSolver (\v flags -> flags { freezeSolver = v }) :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment