Skip to content

Commit 2ed3630

Browse files
mpickeringerikd
authored andcommitted
testsuite: Add two tests for independent goals (haskell#9466)
These tests check how constraints interact with the --independent-goals flag.
1 parent 42aac7e commit 2ed3630

File tree

1 file changed

+29
-0
lines changed
  • cabal-install/tests/UnitTests/Distribution/Solver/Modular

1 file changed

+29
-0
lines changed

cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ tests =
361361
, runTest $ testIndepGoals5 "indepGoals5 - default goal order" DefaultGoalOrder
362362
, runTest $ testIndepGoals6 "indepGoals6 - fixed goal order" FixedGoalOrder
363363
, runTest $ testIndepGoals6 "indepGoals6 - default goal order" DefaultGoalOrder
364+
, expectFailBecause "#9466" $ runTest $ testIndepGoals7 "indepGoals7"
365+
, runTest $ testIndepGoals8 "indepGoals8"
364366
]
365367
, -- Tests designed for the backjumping blog post
366368
testGroup
@@ -2013,6 +2015,33 @@ dbLangs1 =
20132015
, Right $ exAv "C" 1 [ExLang (UnknownLanguage "Haskell3000"), ExAny "B"]
20142016
]
20152017

2018+
-- This test checks how the scope of a constraint interacts with qualified goals.
2019+
-- If you specify `A == 2`, that top-level should /not/ apply to an independent goal!
2020+
testIndepGoals7 :: String -> SolverTest
2021+
testIndepGoals7 name =
2022+
constraints [ExVersionConstraint (scopeToplevel "A") (V.thisVersion (V.mkVersion [2, 0, 0]))] $
2023+
independentGoals $
2024+
mkTest dbIndepGoals78 name ["A"] $
2025+
-- The more recent version should be picked by the solver. As said
2026+
-- above, the top-level A==2 should not apply to an independent goal.
2027+
solverSuccess [("A", 3)]
2028+
2029+
dbIndepGoals78 :: ExampleDb
2030+
dbIndepGoals78 =
2031+
[ Right $ exAv "A" 1 []
2032+
, Right $ exAv "A" 2 []
2033+
, Right $ exAv "A" 3 []
2034+
]
2035+
2036+
-- This test checks how the scope of a constraint interacts with qualified goals.
2037+
-- If you specify `any.A == 2`, then that should apply inside an independent goal.
2038+
testIndepGoals8 :: String -> SolverTest
2039+
testIndepGoals8 name =
2040+
constraints [ExVersionConstraint (ScopeAnyQualifier "A") (V.thisVersion (V.mkVersion [2, 0, 0]))] $
2041+
independentGoals $
2042+
mkTest dbIndepGoals78 name ["A"] $
2043+
solverSuccess [("A", 2)]
2044+
20162045
-- | cabal must set enable-exe to false in order to avoid the unavailable
20172046
-- dependency. Flags are true by default. The flag choice causes "pkg" to
20182047
-- depend on "false-dep".

0 commit comments

Comments
 (0)