Skip to content

Commit

Permalink
testsuite: Add two tests for independent goals (haskell#9466)
Browse files Browse the repository at this point in the history
These tests check how constraints interact with the --independent-goals
flag.
  • Loading branch information
mpickering authored and Mikolaj committed Apr 7, 2024
1 parent 3851043 commit b169cd4
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ tests =
, runTest $ testIndepGoals5 "indepGoals5 - default goal order" DefaultGoalOrder
, runTest $ testIndepGoals6 "indepGoals6 - fixed goal order" FixedGoalOrder
, runTest $ testIndepGoals6 "indepGoals6 - default goal order" DefaultGoalOrder
, expectFailBecause "#9466" $ runTest $ testIndepGoals7 "indepGoals7"
, runTest $ testIndepGoals8 "indepGoals8"
]
, -- Tests designed for the backjumping blog post
testGroup
Expand Down Expand Up @@ -2013,6 +2015,33 @@ dbLangs1 =
, Right $ exAv "C" 1 [ExLang (UnknownLanguage "Haskell3000"), ExAny "B"]
]

-- This test checks how the scope of a constraint interacts with qualified goals.
-- If you specify `A == 2`, that top-level should /not/ apply to an independent goal!
testIndepGoals7 :: String -> SolverTest
testIndepGoals7 name =
constraints [ExVersionConstraint (scopeToplevel "A") (V.thisVersion (V.mkVersion [2, 0, 0]))] $
independentGoals $
mkTest dbIndepGoals78 name ["A"] $
-- The more recent version should be picked by the solver. As said
-- above, the top-level A==2 should not apply to an independent goal.
solverSuccess [("A", 3)]

dbIndepGoals78 :: ExampleDb
dbIndepGoals78 =
[ Right $ exAv "A" 1 []
, Right $ exAv "A" 2 []
, Right $ exAv "A" 3 []
]

-- This test checks how the scope of a constraint interacts with qualified goals.
-- If you specify `any.A == 2`, then that should apply inside an independent goal.
testIndepGoals8 :: String -> SolverTest
testIndepGoals8 name =
constraints [ExVersionConstraint (ScopeAnyQualifier "A") (V.thisVersion (V.mkVersion [2, 0, 0]))] $
independentGoals $
mkTest dbIndepGoals78 name ["A"] $
solverSuccess [("A", 2)]

-- | cabal must set enable-exe to false in order to avoid the unavailable
-- dependency. Flags are true by default. The flag choice causes "pkg" to
-- depend on "false-dep".
Expand Down

0 comments on commit b169cd4

Please sign in to comment.