Skip to content

Commit

Permalink
Add a test case for a stanza preference bug (haskell#3930).
Browse files Browse the repository at this point in the history
  • Loading branch information
grayjay committed Jun 12, 2017
1 parent 9c2aea5 commit 8493661
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ tests = [
, runTest $ preferences [ExStanzaPref "pkg" [TestStanzas]] $
mkTest dbStanzaPreferences2 "disable testing when it's not possible" ["pkg"] $
solverSuccess [("pkg", 1)]

, testStanzaPreference "test stanza preference"
]
, testGroup "Buildable Field" [
testBuildable "avoid building component with unknown dependency" (ExAny "unknown")
Expand Down Expand Up @@ -654,6 +656,32 @@ dbStanzaPreferences2 = [
Right $ exAv "pkg" 1 [] `withTest` ExTest "test" [ExAny "unknown"]
]

-- | This is a test case for a bug in stanza preferences (#3930). The solver
-- should be able to install 'A' by enabling 'flag' and disabling testing. When
-- it tries goals in the specified order and prefers testing, it encounters
-- 'unknown-pkg2'. 'unknown-pkg2' is only introduced by testing and 'flag', so
-- the conflict set should contain both of those variables. Before the fix, it
-- only contained 'flag'. The solver backjumped past the choice to disable
-- testing and failed to find the solution.
testStanzaPreference :: String -> TestTree
testStanzaPreference name =
let pkg = exAv "A" 1 [exFlagged "flag"
[]
[ExAny "unknown-pkg1"]]
`withTest`
ExTest "test" [exFlagged "flag"
[ExAny "unknown-pkg2"]
[]]
goals = [
P None "A"
, F None "A" "flag"
, S None "A" TestStanzas
]
in runTest $ goalOrder goals $
preferences [ ExStanzaPref "A" [TestStanzas]] $
mkTest [Right pkg] name ["A"] $
solverSuccess [("A", 1)]

-- | Database with some cycles
--
-- * Simplest non-trivial cycle: A -> B and B -> A
Expand Down

0 comments on commit 8493661

Please sign in to comment.