@@ -18,6 +18,7 @@ import Language.Haskell.Extension ( Extension(..)
18
18
, KnownExtension (.. ), Language (.. ))
19
19
20
20
-- cabal-install
21
+ import Distribution.Solver.Types.OptionalStanza
21
22
import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb , pkgConfigDbFromList )
22
23
import Distribution.Solver.Types.Settings
23
24
import Distribution.Client.Dependency.Types
@@ -133,7 +134,7 @@ tests = [
133
134
]
134
135
, testGroup " Independent goals" [
135
136
runTest $ indep $ mkTest db16 " indepGoals1" [" A" , " B" ] (SolverSuccess [(" A" , 1 ), (" B" , 1 ), (" C" , 1 ), (" D" , 1 ), (" D" , 2 ), (" E" , 1 )])
136
- , runTest $ indep $ mkTest db17 " indepGoals2" [ " A " , " B " ] ( SolverSuccess [( " A " , 1 ), ( " B " , 1 ), ( " C " , 1 ), ( " D " , 1 )])
137
+ , runTest $ testIndepGoals2 " indepGoals2"
137
138
, runTest $ indep $ mkTest db19 " indepGoals3" [" D" , " E" , " F" ] anySolverFailure -- The target order is important.
138
139
, runTest $ indep $ mkTest db20 " indepGoals4" [" C" , " A" , " B" ] (SolverSuccess [(" A" , 1 ), (" B" , 1 ), (" C" , 1 ), (" D" , 1 ), (" D" , 2 )])
139
140
, runTest $ indep $ mkTest db23 " indepGoals5" [" X" , " Y" ] (SolverSuccess [(" A" , 1 ), (" A" , 2 ), (" B" , 1 ), (" C" , 1 ), (" C" , 2 ), (" X" , 1 ), (" Y" , 1 )])
@@ -157,12 +158,17 @@ tests = [
157
158
-- | Combinator to turn on --independent-goals behavior, i.e. solve
158
159
-- for the goals as if we were solving for each goal independently.
159
160
-- (This doesn't really work well at the moment, see #2842)
160
- indep test = test { testIndepGoals = IndependentGoals True }
161
161
soft prefs test = test { testSoftConstraints = prefs }
162
162
mkvrThis = V. thisVersion . makeV
163
163
mkvrOrEarlier = V. orEarlierVersion . makeV
164
164
makeV v = V. Version [v,0 ,0 ] []
165
165
166
+ indep :: SolverTest -> SolverTest
167
+ indep test = test { testIndepGoals = IndependentGoals True }
168
+
169
+ goalOrder :: [ExampleVar ] -> SolverTest -> SolverTest
170
+ goalOrder order test = test { testGoalOrder = Just order }
171
+
166
172
{- ------------------------------------------------------------------------------
167
173
Solver tests
168
174
-------------------------------------------------------------------------------}
@@ -604,23 +610,41 @@ db16 = [
604
610
, Right $ exAv " E" 1 []
605
611
]
606
612
607
- -- | This database checks that when the solver discovers a constraint on a
613
+ -- | This test checks that when the solver discovers a constraint on a
608
614
-- package's version after choosing to link that package, it can backtrack to
609
615
-- try alternative versions for the linked-to package. See pull request #3327.
610
616
--
611
617
-- When A and B are installed as independent goals, their dependencies on C
612
618
-- must be linked. Since C depends on D, A and B's dependencies on D must also
613
- -- be linked. This test relies on the fact that the solver chooses D-2 for both
614
- -- 0.D and 1.D before it encounters the test suites' constraints. The solver
615
- -- must backtrack to try D-1 for both 0.D and 1.D.
616
- db17 :: ExampleDb
617
- db17 = [
618
- Right $ exAv " A" 1 [ExAny " C" ] `withTest` ExTest " test" [ExFix " D" 1 ]
619
- , Right $ exAv " B" 1 [ExAny " C" ] `withTest` ExTest " test" [ExFix " D" 1 ]
620
- , Right $ exAv " C" 1 [ExAny " D" ]
621
- , Right $ exAv " D" 1 []
622
- , Right $ exAv " D" 2 []
623
- ]
619
+ -- be linked. This test fixes the goal order so that the solver chooses D-2 for
620
+ -- both 0.D and 1.D before it encounters the test suites' constraints. It must
621
+ -- backtrack to try D-1 for both 0.D and 1.D.
622
+ testIndepGoals2 :: String -> SolverTest
623
+ testIndepGoals2 name =
624
+ goalOrder goals $ indep $
625
+ mkTest db name [" A" , " B" ] $
626
+ SolverSuccess [(" A" , 1 ), (" B" , 1 ), (" C" , 1 ), (" D" , 1 )]
627
+ where
628
+ goals :: [ExampleVar ]
629
+ goals = [
630
+ P (Indep 0 ) " A"
631
+ , P (Indep 0 ) " C"
632
+ , P (Indep 0 ) " D"
633
+ , P (Indep 1 ) " B"
634
+ , P (Indep 1 ) " C"
635
+ , P (Indep 1 ) " D"
636
+ , S (Indep 1 ) " B" TestStanzas
637
+ , S (Indep 0 ) " A" TestStanzas
638
+ ]
639
+
640
+ db :: ExampleDb
641
+ db = [
642
+ Right $ exAv " A" 1 [ExAny " C" ] `withTest` ExTest " test" [ExFix " D" 1 ]
643
+ , Right $ exAv " B" 1 [ExAny " C" ] `withTest` ExTest " test" [ExFix " D" 1 ]
644
+ , Right $ exAv " C" 1 [ExAny " D" ]
645
+ , Right $ exAv " D" 1 []
646
+ , Right $ exAv " D" 2 []
647
+ ]
624
648
625
649
-- | Issue #2834
626
650
-- When both A and B are installed as independent goals, their dependencies on
0 commit comments