Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testsuite: Add some unit tests for #9466 #9467 #9468

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
testsuite: Add two tests for independent goals (#9466)
These tests check how constraints interact with the --independent-goals
flag.
mpickering authored and Mikolaj committed Apr 7, 2024
commit b169cd4ae4d4d2a5f790bad4d1b6c19eefa81bc1
Original file line number Diff line number Diff line change
@@ -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"
grayjay marked this conversation as resolved.
Show resolved Hide resolved
, runTest $ testIndepGoals8 "indepGoals8"
]
, -- Tests designed for the backjumping blog post
testGroup
@@ -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".