From 2cee0fe726dba32841ee2088df9d502cd6c9db18 Mon Sep 17 00:00:00 2001 From: Kristen Kozak <grayjay@wordroute.com> Date: Sat, 26 Sep 2015 14:36:06 -0700 Subject: [PATCH] Add test case for backjumping after enforcing SIR --- .../Client/Dependency/Modular/Solver.hs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cabal-install/tests/UnitTests/Distribution/Client/Dependency/Modular/Solver.hs b/cabal-install/tests/UnitTests/Distribution/Client/Dependency/Modular/Solver.hs index d8d854575e..b9346bb39e 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/Dependency/Modular/Solver.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/Dependency/Modular/Solver.hs @@ -125,6 +125,9 @@ tests = [ , runTest $ mkTestPCDepends [("pkgA", "1.0.0"), ("pkgB", "1.0.0")] dbPC1 "pruneNotFound" ["C"] (Just [("A", 1), ("B", 1), ("C", 1)]) , runTest $ mkTestPCDepends [("pkgA", "1.0.0"), ("pkgB", "2.0.0")] dbPC1 "chooseNewest" ["C"] (Just [("A", 1), ("B", 2), ("C", 1)]) ] + , testGroup "Independent goals" [ + runTest $ indep $ mkTest db16 "indepGoals" ["A", "B"] (Just [("A", 1), ("B", 1), ("C", 1), ("D", 1), ("D", 2), ("E", 1)]) + ] ] where -- | Combinator to turn on --independent-goals behavior, i.e. solve @@ -507,6 +510,24 @@ db15 = [ , Right $ exAv "E" 1 [ExFix "C" 2] ] +-- | When A and B are installed as independent goals, the single instance +-- restriction prevents B from depending on C. This database tests that the +-- solver can backtrack after encountering the single instance restriction and +-- choose the only valid flag assignment (-flagA +flagB). +db16 :: ExampleDb +db16 = [ + Right $ exAv "A" 1 [ExAny "C", ExFix "D" 1] + , Right $ exAv "B" 1 [ ExFix "D" 2 + , ExFlag "flagA" + [ExAny "C"] + [ExFlag "flagB" + [ExAny "E"] + [ExAny "C"]]] + , Right $ exAv "C" 1 [ExAny "D"] + , Right $ exAv "D" 1 [] + , Right $ exAv "D" 2 [] + , Right $ exAv "E" 1 [] + ] dbExts1 :: ExampleDb dbExts1 = [ -- GitLab