@@ -216,6 +216,8 @@ tests = [
216
216
, runTest $ preferences [ExStanzaPref " pkg" [TestStanzas ]] $
217
217
mkTest dbStanzaPreferences2 " disable testing when it's not possible" [" pkg" ] $
218
218
solverSuccess [(" pkg" , 1 )]
219
+
220
+ , testStanzaPreference " test stanza preference"
219
221
]
220
222
, testGroup " Buildable Field" [
221
223
testBuildable " avoid building component with unknown dependency" (ExAny " unknown" )
@@ -654,6 +656,32 @@ dbStanzaPreferences2 = [
654
656
Right $ exAv " pkg" 1 [] `withTest` ExTest " test" [ExAny " unknown" ]
655
657
]
656
658
659
+ -- | This is a test case for a bug in stanza preferences (#3930). The solver
660
+ -- should be able to install 'A' by enabling 'flag' and disabling testing. When
661
+ -- it tries goals in the specified order and prefers testing, it encounters
662
+ -- 'unknown-pkg2'. 'unknown-pkg2' is only introduced by testing and 'flag', so
663
+ -- the conflict set should contain both of those variables. Before the fix, it
664
+ -- only contained 'flag'. The solver backjumped past the choice to disable
665
+ -- testing and failed to find the solution.
666
+ testStanzaPreference :: String -> TestTree
667
+ testStanzaPreference name =
668
+ let pkg = exAv " A" 1 [exFlagged " flag"
669
+ []
670
+ [ExAny " unknown-pkg1" ]]
671
+ `withTest`
672
+ ExTest " test" [exFlagged " flag"
673
+ [ExAny " unknown-pkg2" ]
674
+ [] ]
675
+ goals = [
676
+ P None " A"
677
+ , F None " A" " flag"
678
+ , S None " A" TestStanzas
679
+ ]
680
+ in runTest $ goalOrder goals $
681
+ preferences [ ExStanzaPref " A" [TestStanzas ]] $
682
+ mkTest [Right pkg] name [" A" ] $
683
+ solverSuccess [(" A" , 1 )]
684
+
657
685
-- | Database with some cycles
658
686
--
659
687
-- * Simplest non-trivial cycle: A -> B and B -> A
0 commit comments