Unverified Commit 26938a59 authored by quasicomputational's avatar quasicomputational Committed by GitHub

Add --reject-uncsontrained-dependencies (#5475)

This restricts the solver to a closed set of packages.

Previously, even with freeze files, there was no good way to instruct
cabal-install to avoid pulling in extra, unconstrained
packages. `--reject-unconstrained-dependencies=all` forces the solver
to stay within the set of packages that are either local packages,
explicit goals, or which are explicitly constrained in configuration
files or via the `--constraint` flag

Closes #2568.
parent ac968cc0
......@@ -1032,6 +1032,22 @@ The following settings control the behavior of the dependency solver:
index-state: 2016-09-24T17:47:48Z
.. cfg-field:: reject-unconstrained-dependencies: all, none
--reject-unconstrained-dependencies=[all|none]
:synopsis: Restrict the solver to packages that have constraints on them.
:default: none
:since: 2.6
By default, the dependency solver can include any package that it's
aware of in a build plan. If you wish to restrict the build plan to
a closed set of packages (e.g., from a freeze file), use this flag.
When set to `all`, all non-local packages that aren't goals must be
explicitly constrained. When set to `none`, the solver will
consider all packages.
Package configuration options
-----------------------------
......
......@@ -253,6 +253,7 @@ instance Semigroup SavedConfig where
installShadowPkgs = combine installShadowPkgs,
installStrongFlags = combine installStrongFlags,
installAllowBootLibInstalls = combine installAllowBootLibInstalls,
installOnlyConstrained = combine installOnlyConstrained,
installReinstall = combine installReinstall,
installAvoidReinstalls = combine installAvoidReinstalls,
installOverrideReinstall = combine installOverrideReinstall,
......
......@@ -52,6 +52,7 @@ module Distribution.Client.Dependency (
setShadowPkgs,
setStrongFlags,
setAllowBootLibInstalls,
setOnlyConstrained,
setMaxBackjumps,
setEnableBackjumping,
setSolveExecutables,
......@@ -165,6 +166,10 @@ data DepResolverParams = DepResolverParams {
-- | Whether to allow base and its dependencies to be installed.
depResolverAllowBootLibInstalls :: AllowBootLibInstalls,
-- | Whether to only allow explicitly constrained packages plus
-- goals or to allow any package.
depResolverOnlyConstrained :: OnlyConstrained,
depResolverMaxBackjumps :: Maybe Int,
depResolverEnableBackjumping :: EnableBackjumping,
-- | Whether or not to solve for dependencies on executables.
......@@ -195,6 +200,7 @@ showDepResolverParams p =
++ "\nshadow packages: " ++ show (asBool (depResolverShadowPkgs p))
++ "\nstrong flags: " ++ show (asBool (depResolverStrongFlags p))
++ "\nallow boot library installs: " ++ show (asBool (depResolverAllowBootLibInstalls p))
++ "\nonly constrained packages: " ++ show (depResolverOnlyConstrained p)
++ "\nmax backjumps: " ++ maybe "infinite" show
(depResolverMaxBackjumps p)
where
......@@ -250,6 +256,7 @@ basicDepResolverParams installedPkgIndex sourcePkgIndex =
depResolverShadowPkgs = ShadowPkgs False,
depResolverStrongFlags = StrongFlags False,
depResolverAllowBootLibInstalls = AllowBootLibInstalls False,
depResolverOnlyConstrained = OnlyConstrainedNone,
depResolverMaxBackjumps = Nothing,
depResolverEnableBackjumping = EnableBackjumping True,
depResolverSolveExecutables = SolveExecutables True,
......@@ -329,6 +336,12 @@ setAllowBootLibInstalls i params =
depResolverAllowBootLibInstalls = i
}
setOnlyConstrained :: OnlyConstrained -> DepResolverParams -> DepResolverParams
setOnlyConstrained i params =
params {
depResolverOnlyConstrained = i
}
setMaxBackjumps :: Maybe Int -> DepResolverParams -> DepResolverParams
setMaxBackjumps n params =
params {
......@@ -734,7 +747,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
$ fmap (validateSolverResult platform comp indGoals)
$ runSolver solver (SolverConfig reordGoals cntConflicts
indGoals noReinstalls
shadowing strFlags allowBootLibs maxBkjumps enableBj
shadowing strFlags allowBootLibs onlyConstrained_ maxBkjumps enableBj
solveExes order verbosity (PruneAfterFirstSuccess False))
platform comp installedPkgIndex sourcePkgIndex
pkgConfigDB preferences constraints targets
......@@ -752,6 +765,7 @@ resolveDependencies platform comp pkgConfigDB solver params =
shadowing
strFlags
allowBootLibs
onlyConstrained_
maxBkjumps
enableBj
solveExes
......@@ -993,7 +1007,7 @@ resolveWithoutDependencies (DepResolverParams targets constraints
prefs defpref installedPkgIndex sourcePkgIndex
_reorderGoals _countConflicts _indGoals _avoidReinstalls
_shadowing _strFlags _maxBjumps _enableBj
_solveExes _allowBootLibInstalls _order _verbosity) =
_solveExes _allowBootLibInstalls _onlyConstrained _order _verbosity) =
collectEithers $ map selectPackage (Set.toList targets)
where
selectPackage :: PackageName -> Either ResolveNoDepsError UnresolvedSourcePackage
......
......@@ -168,6 +168,8 @@ planPackages verbosity comp platform fetchFlags
. setAllowBootLibInstalls allowBootLibInstalls
. setOnlyConstrained onlyConstrained
. setSolverVerbosity verbosity
. addConstraints
......@@ -200,6 +202,7 @@ planPackages verbosity comp platform fetchFlags
strongFlags = fromFlag (fetchStrongFlags fetchFlags)
maxBackjumps = fromFlag (fetchMaxBackjumps fetchFlags)
allowBootLibInstalls = fromFlag (fetchAllowBootLibInstalls fetchFlags)
onlyConstrained = fromFlag (fetchOnlyConstrained fetchFlags)
checkTarget :: Verbosity -> UserTarget -> IO ()
......
......@@ -181,6 +181,8 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
. setAllowBootLibInstalls allowBootLibInstalls
. setOnlyConstrained onlyConstrained
. setSolverVerbosity verbosity
. addConstraints
......@@ -208,6 +210,7 @@ planPackages verbosity comp platform mSandboxPkgInfo freezeFlags
strongFlags = fromFlag (freezeStrongFlags freezeFlags)
maxBackjumps = fromFlag (freezeMaxBackjumps freezeFlags)
allowBootLibInstalls = fromFlag (freezeAllowBootLibInstalls freezeFlags)
onlyConstrained = fromFlag (freezeOnlyConstrained freezeFlags)
-- | Remove all unneeded packages from an install plan.
......
......@@ -392,6 +392,8 @@ planPackages verbosity comp platform mSandboxPkgInfo solver
. setAllowBootLibInstalls allowBootLibInstalls
. setOnlyConstrained onlyConstrained
. setSolverVerbosity verbosity
. setPreferenceDefault (if upgradeDeps then PreferAllLatest
......@@ -454,6 +456,7 @@ planPackages verbosity comp platform mSandboxPkgInfo solver
strongFlags = fromFlag (installStrongFlags installFlags)
maxBackjumps = fromFlag (installMaxBackjumps installFlags)
allowBootLibInstalls = fromFlag (installAllowBootLibInstalls installFlags)
onlyConstrained = fromFlag (installOnlyConstrained installFlags)
upgradeDeps = fromFlag (installUpgradeDeps installFlags)
onlyDeps = fromFlag (installOnlyDeps installFlags)
......
......@@ -237,6 +237,7 @@ resolveSolverSettings ProjectConfig{
solverSettingCountConflicts = fromFlag projectConfigCountConflicts
solverSettingStrongFlags = fromFlag projectConfigStrongFlags
solverSettingAllowBootLibInstalls = fromFlag projectConfigAllowBootLibInstalls
solverSettingOnlyConstrained = fromFlag projectConfigOnlyConstrained
solverSettingIndexState = flagToMaybe projectConfigIndexState
solverSettingIndependentGoals = fromFlag projectConfigIndependentGoals
--solverSettingShadowPkgs = fromFlag projectConfigShadowPkgs
......@@ -256,6 +257,7 @@ resolveSolverSettings ProjectConfig{
projectConfigCountConflicts = Flag (CountConflicts True),
projectConfigStrongFlags = Flag (StrongFlags False),
projectConfigAllowBootLibInstalls = Flag (AllowBootLibInstalls False),
projectConfigOnlyConstrained = Flag OnlyConstrainedNone,
projectConfigIndependentGoals = Flag (IndependentGoals False)
--projectConfigShadowPkgs = Flag False,
--projectConfigReinstall = Flag False,
......
......@@ -342,7 +342,8 @@ convertLegacyAllPackageFlags globalFlags configFlags
installIndependentGoals = projectConfigIndependentGoals,
--installShadowPkgs = projectConfigShadowPkgs,
installStrongFlags = projectConfigStrongFlags,
installAllowBootLibInstalls = projectConfigAllowBootLibInstalls
installAllowBootLibInstalls = projectConfigAllowBootLibInstalls,
installOnlyConstrained = projectConfigOnlyConstrained
} = installFlags
......@@ -556,6 +557,7 @@ convertToLegacySharedConfig
installShadowPkgs = mempty, --projectConfigShadowPkgs,
installStrongFlags = projectConfigStrongFlags,
installAllowBootLibInstalls = projectConfigAllowBootLibInstalls,
installOnlyConstrained = projectConfigOnlyConstrained,
installOnly = mempty,
installOnlyDeps = projectConfigOnlyDeps,
installIndexState = projectConfigIndexState,
......@@ -916,7 +918,7 @@ legacySharedConfigFieldDescrs =
, "one-shot", "jobs", "keep-going", "offline", "per-component"
-- solver flags:
, "max-backjumps", "reorder-goals", "count-conflicts", "independent-goals"
, "strong-flags" , "allow-boot-library-installs", "index-state"
, "strong-flags" , "allow-boot-library-installs", "reject-unconstrained-dependencies", "index-state"
]
. commandOptionsToFields
) (installOptions ParseArgs)
......
......@@ -191,6 +191,7 @@ data ProjectConfigShared
projectConfigCountConflicts :: Flag CountConflicts,
projectConfigStrongFlags :: Flag StrongFlags,
projectConfigAllowBootLibInstalls :: Flag AllowBootLibInstalls,
projectConfigOnlyConstrained :: Flag OnlyConstrained,
projectConfigPerComponent :: Flag Bool,
projectConfigIndependentGoals :: Flag IndependentGoals,
......@@ -372,6 +373,7 @@ data SolverSettings
solverSettingCountConflicts :: CountConflicts,
solverSettingStrongFlags :: StrongFlags,
solverSettingAllowBootLibInstalls :: AllowBootLibInstalls,
solverSettingOnlyConstrained :: OnlyConstrained,
solverSettingIndexState :: Maybe IndexState,
solverSettingIndependentGoals :: IndependentGoals
-- Things that only make sense for manual mode, not --local mode
......
......@@ -960,6 +960,8 @@ planPackages verbosity comp platform solver SolverSettings{..}
. setAllowBootLibInstalls solverSettingAllowBootLibInstalls
. setOnlyConstrained solverSettingOnlyConstrained
. setSolverVerbosity verbosity
--TODO: [required eventually] decide if we need to prefer
......
......@@ -919,6 +919,7 @@ data FetchFlags = FetchFlags {
fetchShadowPkgs :: Flag ShadowPkgs,
fetchStrongFlags :: Flag StrongFlags,
fetchAllowBootLibInstalls :: Flag AllowBootLibInstalls,
fetchOnlyConstrained :: Flag OnlyConstrained,
fetchTests :: Flag Bool,
fetchBenchmarks :: Flag Bool,
fetchVerbosity :: Flag Verbosity
......@@ -937,6 +938,7 @@ defaultFetchFlags = FetchFlags {
fetchShadowPkgs = Flag (ShadowPkgs False),
fetchStrongFlags = Flag (StrongFlags False),
fetchAllowBootLibInstalls = Flag (AllowBootLibInstalls False),
fetchOnlyConstrained = Flag OnlyConstrainedNone,
fetchTests = toFlag False,
fetchBenchmarks = toFlag False,
fetchVerbosity = toFlag normal
......@@ -997,6 +999,7 @@ fetchCommand = CommandUI {
fetchShadowPkgs (\v flags -> flags { fetchShadowPkgs = v })
fetchStrongFlags (\v flags -> flags { fetchStrongFlags = v })
fetchAllowBootLibInstalls (\v flags -> flags { fetchAllowBootLibInstalls = v })
fetchOnlyConstrained (\v flags -> flags { fetchOnlyConstrained = v })
}
......@@ -1016,6 +1019,7 @@ data FreezeFlags = FreezeFlags {
freezeShadowPkgs :: Flag ShadowPkgs,
freezeStrongFlags :: Flag StrongFlags,
freezeAllowBootLibInstalls :: Flag AllowBootLibInstalls,
freezeOnlyConstrained :: Flag OnlyConstrained,
freezeVerbosity :: Flag Verbosity
}
......@@ -1032,6 +1036,7 @@ defaultFreezeFlags = FreezeFlags {
freezeShadowPkgs = Flag (ShadowPkgs False),
freezeStrongFlags = Flag (StrongFlags False),
freezeAllowBootLibInstalls = Flag (AllowBootLibInstalls False),
freezeOnlyConstrained = Flag OnlyConstrainedNone,
freezeVerbosity = toFlag normal
}
......@@ -1083,6 +1088,7 @@ freezeCommand = CommandUI {
freezeShadowPkgs (\v flags -> flags { freezeShadowPkgs = v })
freezeStrongFlags (\v flags -> flags { freezeStrongFlags = v })
freezeAllowBootLibInstalls (\v flags -> flags { freezeAllowBootLibInstalls = v })
freezeOnlyConstrained (\v flags -> flags { freezeOnlyConstrained = v })
}
......@@ -1651,6 +1657,7 @@ data InstallFlags = InstallFlags {
installShadowPkgs :: Flag ShadowPkgs,
installStrongFlags :: Flag StrongFlags,
installAllowBootLibInstalls :: Flag AllowBootLibInstalls,
installOnlyConstrained :: Flag OnlyConstrained,
installReinstall :: Flag Bool,
installAvoidReinstalls :: Flag AvoidReinstalls,
installOverrideReinstall :: Flag Bool,
......@@ -1696,6 +1703,7 @@ defaultInstallFlags = InstallFlags {
installShadowPkgs = Flag (ShadowPkgs False),
installStrongFlags = Flag (StrongFlags False),
installAllowBootLibInstalls = Flag (AllowBootLibInstalls False),
installOnlyConstrained = Flag OnlyConstrainedNone,
installReinstall = Flag False,
installAvoidReinstalls = Flag (AvoidReinstalls False),
installOverrideReinstall = Flag False,
......@@ -1889,7 +1897,8 @@ installOptions showOrParseArgs =
installIndependentGoals (\v flags -> flags { installIndependentGoals = v })
installShadowPkgs (\v flags -> flags { installShadowPkgs = v })
installStrongFlags (\v flags -> flags { installStrongFlags = v })
installAllowBootLibInstalls (\v flags -> flags { installAllowBootLibInstalls = v }) ++
installAllowBootLibInstalls (\v flags -> flags { installAllowBootLibInstalls = v })
installOnlyConstrained (\v flags -> flags { installOnlyConstrained = v }) ++
[ option [] ["reinstall"]
"Install even if it means installing the same version again."
......@@ -2720,9 +2729,10 @@ optionSolverFlags :: ShowOrParseArgs
-> (flags -> Flag ShadowPkgs) -> (Flag ShadowPkgs -> flags -> flags)
-> (flags -> Flag StrongFlags) -> (Flag StrongFlags -> flags -> flags)
-> (flags -> Flag AllowBootLibInstalls) -> (Flag AllowBootLibInstalls -> flags -> flags)
-> (flags -> Flag OnlyConstrained) -> (Flag OnlyConstrained -> flags -> flags)
-> [OptionField flags]
optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg getcc setcc getig setig
getsip setsip getstrfl setstrfl getib setib =
getsip setsip getstrfl setstrfl getib setib getoc setoc =
[ option [] ["max-backjumps"]
("Maximum number of backjumps allowed while solving (default: " ++ show defaultMaxBackjumps ++ "). Use a negative number to enable unlimited backtracking. Use 0 to disable backtracking completely.")
getmbj setmbj
......@@ -2758,6 +2768,16 @@ optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg getcc setcc getig se
(fmap asBool . getib)
(setib . fmap AllowBootLibInstalls)
(yesNoOpt showOrParseArgs)
, option [] ["reject-unconstrained-dependencies"]
"Require these packages to have constraints on them if they are to be selected (default: none)."
getoc
setoc
(reqArg "none|all"
(readP_to_E
(const "reject-unconstrained-dependencies must be 'none' or 'all'")
(toFlag `fmap` parse))
(flagToList . fmap display))
]
usageFlagsOrPackages :: String -> String -> String
......
module Distribution.Solver.Modular
( modularResolver, SolverConfig(..), PruneAfterFirstSuccess(..)) where
( modularResolver, SolverConfig(..), PruneAfterFirstSuccess(..) ) where
-- Here, we try to map between the external cabal-install solver
-- interface and the internal interface that the solver actually
......
......@@ -115,6 +115,7 @@ showFR _ (PackageRequiresMissingComponent qpn comp) = " (requires " ++ showExpos
showFR _ (PackageRequiresUnbuildableComponent qpn comp) = " (requires " ++ showExposedComponent comp ++ " from " ++ showQPN qpn ++ ", but the component is not buildable in the current environment)"
showFR _ CannotInstall = " (only already installed instances can be used)"
showFR _ CannotReinstall = " (avoiding to reinstall a package with same version but new dependencies)"
showFR _ NotExplicit = " (not a user-provided goal nor mentioned as a constraint, but reject-unconstrained-dependencies was set)"
showFR _ Shadowed = " (shadowed by another installed package with same version)"
showFR _ Broken = " (package is broken)"
showFR _ (GlobalConstraintVersion vr src) = " (" ++ constraintSource src ++ " requires " ++ display vr ++ ")"
......
......@@ -13,6 +13,7 @@ module Distribution.Solver.Modular.Preference
, preferPackagePreferences
, preferReallyEasyGoalChoices
, requireInstalled
, onlyConstrained
, sortGoals
, pruneAfterFirstSuccess
) where
......@@ -337,6 +338,15 @@ avoidReinstalls p = trav go
x
go x = x
-- | Require all packages to be mentioned in a constraint or as a goal.
onlyConstrained :: (PN -> Bool) -> Tree d QGoalReason -> Tree d QGoalReason
onlyConstrained p = trav go
where
go (PChoiceF v@(Q _ pn) _ gr _) | not (p pn)
= FailF (varToConflictSet (P v) `CS.union` goalReasonToCS gr) NotExplicit
go x
= x
-- | Sort all goals using the provided function.
sortGoals :: (Variable QPN -> Variable QPN -> Ordering) -> Tree d c -> Tree d c
sortGoals variableOrder = trav go
......
......@@ -62,6 +62,7 @@ data SolverConfig = SolverConfig {
shadowPkgs :: ShadowPkgs,
strongFlags :: StrongFlags,
allowBootLibInstalls :: AllowBootLibInstalls,
onlyConstrained :: OnlyConstrained,
maxBackjumps :: Maybe Int,
enableBackjumping :: EnableBackjumping,
solveExecutables :: SolveExecutables,
......@@ -129,10 +130,20 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
prunePhase = (if asBool (avoidReinstalls sc) then P.avoidReinstalls (const True) else id) .
(if asBool (allowBootLibInstalls sc)
then id
else P.requireInstalled (`elem` nonInstallable))
else P.requireInstalled (`elem` nonInstallable)) .
(case onlyConstrained sc of
OnlyConstrainedAll ->
P.onlyConstrained pkgIsExplicit
OnlyConstrainedNone ->
id)
buildPhase = traceTree "build.json" id
$ buildTree idx (independentGoals sc) (S.toList userGoals)
allExplicit = M.keysSet userConstraints `S.union` userGoals
pkgIsExplicit :: PN -> Bool
pkgIsExplicit pn = S.member pn allExplicit
-- packages that can never be installed or upgraded
-- If you change this enumeration, make sure to update the list in
-- "Distribution.Client.Dependency" as well
......
......@@ -106,6 +106,7 @@ data FailReason = UnsupportedExtension Extension
| PackageRequiresUnbuildableComponent QPN ExposedComponent
| CannotInstall
| CannotReinstall
| NotExplicit
| Shadowed
| Broken
| GlobalConstraintVersion VR ConstraintSource
......
......@@ -7,6 +7,7 @@ module Distribution.Solver.Types.Settings
, ShadowPkgs(..)
, StrongFlags(..)
, AllowBootLibInstalls(..)
, OnlyConstrained(..)
, EnableBackjumping(..)
, CountConflicts(..)
, SolveExecutables(..)
......@@ -14,8 +15,13 @@ module Distribution.Solver.Types.Settings
import Distribution.Simple.Setup ( BooleanFlag(..) )
import Distribution.Compat.Binary (Binary(..))
import Distribution.Pretty ( Pretty(pretty) )
import Distribution.Text ( Text(parse) )
import GHC.Generics (Generic)
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as PP
newtype ReorderGoals = ReorderGoals Bool
deriving (BooleanFlag, Eq, Generic, Show)
......@@ -37,6 +43,13 @@ newtype StrongFlags = StrongFlags Bool
newtype AllowBootLibInstalls = AllowBootLibInstalls Bool
deriving (BooleanFlag, Eq, Generic, Show)
-- | Should we consider all packages we know about, or only those that
-- have constraints explicitly placed on them or which are goals?
data OnlyConstrained
= OnlyConstrainedNone
| OnlyConstrainedAll
deriving (Eq, Generic, Show)
newtype EnableBackjumping = EnableBackjumping Bool
deriving (BooleanFlag, Eq, Generic, Show)
......@@ -50,4 +63,16 @@ instance Binary AvoidReinstalls
instance Binary ShadowPkgs
instance Binary StrongFlags
instance Binary AllowBootLibInstalls
instance Binary OnlyConstrained
instance Binary SolveExecutables
instance Pretty OnlyConstrained where
pretty OnlyConstrainedAll = PP.text "all"
pretty OnlyConstrainedNone = PP.text "none"
instance Text OnlyConstrained where
parse = Parse.choice
[ Parse.string "all" >> return OnlyConstrainedAll
, Parse.string "none" >> return OnlyConstrainedNone
]
-*-change-log-*-
2.4.0.0 (current development version)
2.6.0.0 (current development version)
* New solver flag: '--reject-unconstrained-dependencies'. (#2568)
2.4.0.0
* 'new-run' now allows the user to run scripts that use a special block
to define their requirements (as in the executable stanza) in place
of a target. This also allows the use of 'cabal' as an interpreter
......
......@@ -436,6 +436,7 @@ instance Arbitrary ProjectConfigShared where
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> (toNubList <$> listOf arbitraryShortToken)
where
arbitraryConstraints :: Gen [(UserConstraint, ConstraintSource)]
......@@ -462,10 +463,11 @@ instance Arbitrary ProjectConfigShared where
, projectConfigCountConflicts = x17
, projectConfigStrongFlags = x18
, projectConfigAllowBootLibInstalls = x19
, projectConfigPerComponent = x20
, projectConfigIndependentGoals = x21
, projectConfigConfigFile = x22
, projectConfigProgPathExtra = x23} =
, projectConfigOnlyConstrained = x20
, projectConfigPerComponent = x21
, projectConfigIndependentGoals = x22
, projectConfigConfigFile = x23
, projectConfigProgPathExtra = x24} =
[ ProjectConfigShared { projectConfigDistDir = x00'
, projectConfigProjectFile = x01'
, projectConfigHcFlavor = x02'
......@@ -486,21 +488,22 @@ instance Arbitrary ProjectConfigShared where
, projectConfigCountConflicts = x17'
, projectConfigStrongFlags = x18'
, projectConfigAllowBootLibInstalls = x19'
, projectConfigPerComponent = x20'
, projectConfigIndependentGoals = x21'
, projectConfigConfigFile = x22'
, projectConfigProgPathExtra = x23'}
, projectConfigOnlyConstrained = x20'
, projectConfigPerComponent = x21'
, projectConfigIndependentGoals = x22'
, projectConfigConfigFile = x23'
, projectConfigProgPathExtra = x24'}
| ((x00', x01', x02', x03', x04'),
(x05', x06', x07', x08', x09'),
(x10', x11', x12', x13', x14'),
(x15', x16', x17', x18', x19'),
x20', x21', x22', x23')
x20', x21', x22', x23', x24')
<- shrink
((x00, x01, x02, fmap NonEmpty x03, fmap NonEmpty x04),
(x05, x06, x07, x08, preShrink_Constraints x09),
(x10, x11, x12, x13, x14),
(x15, x16, x17, x18, x19),
x20, x21, x22, x23)
x20, x21, x22, x23, x24)
]
where
preShrink_Constraints = map fst
......@@ -811,6 +814,11 @@ instance Arbitrary StrongFlags where
instance Arbitrary AllowBootLibInstalls where
arbitrary = AllowBootLibInstalls <$> arbitrary
instance Arbitrary OnlyConstrained where
arbitrary = oneof [ pure OnlyConstrainedAll
, pure OnlyConstrainedNone
]
instance Arbitrary AllowNewer where
arbitrary = AllowNewer <$> arbitrary
......
......@@ -648,6 +648,7 @@ exResolve :: ExampleDb
-> IndependentGoals
-> ReorderGoals
-> AllowBootLibInstalls
-> OnlyConstrained
-> EnableBackjumping
-> SolveExecutables
-> Maybe (Variable P.QPN -> Variable P.QPN -> Ordering)
......@@ -657,7 +658,7 @@ exResolve :: ExampleDb
-> EnableAllTests
-> Progress String String CI.SolverInstallPlan.SolverInstallPlan
exResolve db exts langs pkgConfigDb targets mbj countConflicts indepGoals
reorder allowBootLibInstalls enableBj solveExes goalOrder constraints
reorder allowBootLibInstalls onlyConstrained enableBj solveExes goalOrder constraints
prefs verbosity enableAllTests
= resolveDependencies C.buildPlatform compiler pkgConfigDb Modular params
where
......@@ -686,6 +687,7 @@ exResolve db exts langs pkgConfigDb targets mbj countConflicts indepGoals
$ setReorderGoals reorder
$ setMaxBackjumps mbj
$ setAllowBootLibInstalls allowBootLibInstalls
$ setOnlyConstrained onlyConstrained
$ setEnableBackjumping enableBj
$ setSolveExecutables solveExes
$ setGoalOrder goalOrder
......
......@@ -6,6 +6,7 @@ module UnitTests.Distribution.Solver.Modular.DSL.TestCaseUtils (
, maxBackjumps
, independentGoals
, allowBootLibInstalls
, onlyConstrained
, disableBackjumping
, disableSolveExecutables
, goalOrder
......@@ -61,6 +62,10 @@ allowBootLibInstalls :: SolverTest -> SolverTest
allowBootLibInstalls test =
test { testAllowBootLibInstalls = AllowBootLibInstalls True }
onlyConstrained :: SolverTest -> SolverTest
onlyConstrained test =
test { testOnlyConstrained = OnlyConstrainedAll }
disableBackjumping :: SolverTest -> SolverTest
disableBackjumping test =
test { testEnableBackjumping = EnableBackjumping False }
......@@ -97,6 +102,7 @@ data SolverTest = SolverTest {
, testMaxBackjumps :: Maybe Int
, testIndepGoals :: IndependentGoals
, testAllowBootLibInstalls :: AllowBootLibInstalls
, testOnlyConstrained :: OnlyConstrained
, testEnableBackjumping :: EnableBackjumping
, testSolveExecutables :: SolveExecutables
, testGoalOrder :: Maybe [ExampleVar]
......@@ -191,6 +197,7 @@ mkTestExtLangPC exts langs pkgConfigDb db label targets result = SolverTest {
, testMaxBackjumps = Nothing
, testIndepGoals = IndependentGoals False
, testAllowBootLibInstalls = AllowBootLibInstalls False
, testOnlyConstrained = OnlyConstrainedNone
, testEnableBackjumping = EnableBackjumping True
, testSolveExecutables = SolveExecutables True
, testGoalOrder = Nothing
......@@ -211,7 +218,7 @@ runTest SolverTest{..} = askOption $ \(OptionShowSolverLog showSolverLog) ->
testSupportedLangs testPkgConfigDb testTargets
testMaxBackjumps (CountConflicts True) testIndepGoals
(ReorderGoals False) testAllowBootLibInstalls
testEnableBackjumping testSolveExecutables
testOnlyConstrained testEnableBackjumping testSolveExecutables
(sortGoals <$> testGoalOrder) testConstraints
testSoftConstraints testVerbosity testEnableAllTests
printMsg msg = when showSolverLog $ putStrLn msg
......
......@@ -144,7 +144,7 @@ solve enableBj reorder countConflicts indep goalOrder test =
-- too much time and memory.
(Just defaultMaxBackjumps)
countConflicts indep reorder (AllowBootLibInstalls False)
enableBj (SolveExecutables True) (unVarOrdering <$> goalOrder)
OnlyConstrainedNone enableBj (SolveExecutables True) (unVarOrdering <$> goalOrder)
(testConstraints test) (testPreferences test) normal
(EnableAllTests False)
......
......@@ -152,6 +152,14 @@ tests = [
, runTest $ allowBootLibInstalls $ mkTest dbBase "Install base with --allow-boot-library-installs" ["base"] $
solverSuccess [("base", 1), ("ghc-prim", 1), ("integer-gmp", 1), ("integer-simple", 1)]
]