Commit a9dc1996 authored by barmston's avatar barmston

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 (
import Distribution.Client.Config ( SavedConfig(..) )
import Distribution.Client.Types
import Distribution.Client.Targets
import Distribution.Client.Dependency hiding ( addConstraints )
import Distribution.Client.Dependency
import Distribution.Client.IndexUtils as IndexUtils
( getSourcePackages, getInstalledPackages )
import Distribution.Client.InstallPlan
......@@ -41,7 +41,7 @@ import qualified Distribution.Client.PackageIndex as PackageIndex
import Distribution.Simple.Program
( ProgramConfiguration )
import Distribution.Simple.Setup
( fromFlag )
( fromFlag, fromFlagOrDefault )
import Distribution.Simple.Utils
( die, notice, debug, writeFileAtomic )
import Distribution.System
......@@ -156,12 +156,23 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
. setShadowPkgs shadowPkgs
. addConstraints
[ PackageConstraintStanzas (pkgSpecifierTarget pkgSpecifier) stanzas
| pkgSpecifier <- pkgSpecifiers ]
. maybe id applySandboxInstallPolicy mSandboxPkgInfo
$ standardInstallPolicy installedPkgIndex sourcePkgDb pkgSpecifiers
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)
independentGoals = fromFlag (freezeIndependentGoals freezeFlags)
shadowPkgs = fromFlag (freezeShadowPkgs freezeFlags)
......@@ -189,10 +200,11 @@ pruneInstallPlan installPlan pkgSpecifiers =
freezePackages :: Package pkg => Verbosity -> [pkg] -> IO ()
freezePackages verbosity pkgs = do
pkgEnv <- fmap (createPkgEnv . addConstraints) $ loadUserConfig verbosity ""
pkgEnv <- fmap (createPkgEnv . addFrozenConstraints) $
loadUserConfig verbosity ""
writeFileAtomic userPackageEnvironmentFile $ showPkgEnv pkgEnv
where
addConstraints config =
addFrozenConstraints config =
config {
savedConfigureExFlags = (savedConfigureExFlags config) {
configExConstraints = constraints pkgs
......
......@@ -547,6 +547,8 @@ fetchCommand = CommandUI {
data FreezeFlags = FreezeFlags {
freezeDryRun :: Flag Bool,
freezeTests :: Flag Bool,
freezeBenchmarks :: Flag Bool,
freezeSolver :: Flag PreSolver,
freezeMaxBackjumps :: Flag Int,
freezeReorderGoals :: Flag Bool,
......@@ -558,6 +560,8 @@ data FreezeFlags = FreezeFlags {
defaultFreezeFlags :: FreezeFlags
defaultFreezeFlags = FreezeFlags {
freezeDryRun = toFlag False,
freezeTests = toFlag False,
freezeBenchmarks = toFlag False,
freezeSolver = Flag defaultSolver,
freezeMaxBackjumps = Flag defaultMaxBackjumps,
freezeReorderGoals = Flag False,
......@@ -581,6 +585,16 @@ freezeCommand = CommandUI {
freezeDryRun (\v flags -> flags { freezeDryRun = v })
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 }) :
......
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