Skip to content

Commit 58452a1

Browse files
committed
testsuite: Add two tests for independent goals (haskell#9466)
These tests check how constraints interact with the --independent-goals flag.
1 parent 13e129a commit 58452a1

File tree

1 file changed

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

1 file changed

+39
-0
lines changed

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

Lines changed: 39 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
@@ -1968,6 +1970,43 @@ dbLangs1 =
19681970
, Right $ exAv "C" 1 [ExLang (UnknownLanguage "Haskell3000"), ExAny "B"]
19691971
]
19701972

1973+
-- This test checks how the scope of a constraint interacts with qualified goals.
1974+
-- If you specify `B == 2`, then should that apply to an independent goal or not?
1975+
testIndepGoals7 :: String -> SolverTest
1976+
testIndepGoals7 name =
1977+
constraints [ExVersionConstraint (scopeToplevel "B") (V.thisVersion (V.mkVersion [2,0,0]))] $
1978+
independentGoals $
1979+
mkTest db name ["A"] $
1980+
-- TODO: Place correct string here when it fails
1981+
solverFailure (const False)
1982+
where
1983+
db :: ExampleDb
1984+
db =
1985+
[ Right $ exAv "A" 1 [ExAny "B"]
1986+
, Right $ exAv "B" 1 [ExAny "does-not-exist"]
1987+
, Right $ exAv "B" 2 []
1988+
, Right $ exAv "B" 3 [ExAny "does-not-exist"]
1989+
]
1990+
1991+
-- This test checks how the scope of a constraint interacts with qualified goals.
1992+
-- If you specify `any.B == 2`, then that should apply inside an independent goal.
1993+
testIndepGoals8 :: String -> SolverTest
1994+
testIndepGoals8 name =
1995+
constraints [ExVersionConstraint (ScopeAnyQualifier "B") (V.thisVersion (V.mkVersion [2,0,0]))] $
1996+
independentGoals $
1997+
mkTest db name ["A"] $
1998+
solverSuccess [("A", 1), ("B", 2)]
1999+
where
2000+
db :: ExampleDb
2001+
db =
2002+
[ Right $ exAv "A" 1 [ExAny "B"]
2003+
, Right $ exAv "B" 1 []
2004+
, Right $ exAv "B" 2 []
2005+
, Right $ exAv "B" 3 []
2006+
]
2007+
2008+
2009+
19712010
-- | cabal must set enable-exe to false in order to avoid the unavailable
19722011
-- dependency. Flags are true by default. The flag choice causes "pkg" to
19732012
-- depend on "false-dep".

0 commit comments

Comments
 (0)