Skip to content

Commit 009e43f

Browse files
committed
Solver: shorten the skipping message if needed
Also add a test to prevent this regressing. Closes: #4251
1 parent 7af1389 commit 009e43f

File tree

3 files changed

+24
-3
lines changed
  • cabal-install-solver/src/Distribution/Solver/Modular
  • cabal-install/tests/UnitTests/Distribution/Solver/Modular
  • changelog.d

3 files changed

+24
-3
lines changed

cabal-install-solver/src/Distribution/Solver/Modular/Message.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,16 @@ showOption qpn@(Q _pp pn) (POption i linkedTo) =
282282
-- >>> showOptions foobarQPN [k1, k2]
283283
-- "foo-bar; foo-bar~>bazqux.foo-bar-1, foo-bar~>bazqux.foo-bar-2"
284284
-- >>> showOptions foobarQPN [v0, i1, k2]
285-
-- "foo-bar; 0, 1/installed-inplace, foo-bar~>bazqux.foo-bar-2"
285+
-- "foo-bar; 0, 1/installed-inplace, foo-bar~>bazqux.foo-bar-2 and earlier versions"
286286
showOptions :: QPN -> [POption] -> String
287287
showOptions _ [] = "unexpected empty list of versions"
288288
showOptions q [x] = showOption q x
289289
showOptions q xs = showQPN q ++ "; " ++ (L.intercalate ", "
290290
[if isJust linkedTo
291291
then showOption q x
292292
else showI i -- Don't show the package, just the version
293-
| x@(POption i linkedTo) <- xs
294-
])
293+
| x@(POption i linkedTo) <- take 3 xs
294+
] ++ if length xs >= 3 then " and earlier versions" else "")
295295

296296
showGR :: QGoalReason -> String
297297
showGR UserGoal = " (user goal)"

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,19 @@ tests =
964964
skipping = "skipping: A; 2.0.0/installed-2.0.0, 1.0.0/installed-1.0.0"
965965
in mkTest db "show skipping versions list, installed" ["B"] $
966966
solverFailure (\msg -> rejecting `isInfixOf` msg && skipping `isInfixOf` msg)
967+
, runTest $
968+
let db =
969+
[ Right $ exAv "A" 1 []
970+
, Right $ exAv "A" 2 []
971+
, Right $ exAv "A" 3 []
972+
, Right $ exAv "A" 4 []
973+
, Right $ exAv "A" 5 []
974+
, Right $ exAv "B" 1 [ExFix "A" 6]
975+
]
976+
rejecting = "rejecting: A-5.0.0 (conflict: B => A==6.0.0)"
977+
skipping = "skipping: A; 4.0.0, 3.0.0, 2.0.0 and earlier versions (has"
978+
in mkTest db "show summarized skipping versions list" ["B"] $
979+
solverFailure (\msg -> rejecting `isInfixOf` msg && skipping `isInfixOf` msg)
967980
]
968981
]
969982
]

changelog.d/pr-11062

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
synopsis: Solver: shorten the skipping message if needed
2+
packages: cabal-install-solver
3+
prs: #11062
4+
5+
When the solver fails to find a solution, it can print out a long list
6+
of package versions which failed to meet the requirements. This PR
7+
shortens the message to at most 3 versions which failed to meet the
8+
requriements.

0 commit comments

Comments
 (0)