diff --git a/cabal-install/Distribution/Solver/Modular/Package.hs b/cabal-install/Distribution/Solver/Modular/Package.hs index d5226700c32..eb68ab25340 100644 --- a/cabal-install/Distribution/Solver/Modular/Package.hs +++ b/cabal-install/Distribution/Solver/Modular/Package.hs @@ -18,8 +18,7 @@ module Distribution.Solver.Modular.Package , unPN ) where -import Prelude () -import Distribution.Solver.Compat.Prelude +import Data.List as L import Distribution.Package -- from Cabal import Distribution.Deprecated.Text (display) @@ -58,12 +57,14 @@ data I = I Ver Loc -- | String representation of an instance. showI :: I -> String showI (I v InRepo) = showVer v -showI (I v (Inst uid)) = showVer v ++ "/installed" ++ extractPackageAbiHash uid +showI (I v (Inst uid)) = showVer v ++ "/installed" ++ shortId uid where - extractPackageAbiHash xs = - case first reverse $ break (=='-') $ reverse (display xs) of - (ys, []) -> ys - (ys, _) -> '-' : ys + -- A hack to extract the beginning of the package ABI hash + shortId = snip (splitAt 4) (++ "...") + . snip ((\ (x, y) -> (reverse x, y)) . break (=='-') . reverse) ('-':) + . display + snip p f xs = case p xs of + (ys, zs) -> (if L.null zs then id else f) ys -- | Package instance. A package name and an instance. data PI qpn = PI qpn I diff --git a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs index 965ea669441..c4405a9974e 100644 --- a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs +++ b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/Solver.hs @@ -708,15 +708,6 @@ tests = [ "minimize conflict set with --minimize-conflict-set" , testNoMinimizeConflictSet "show original conflict set with --no-minimize-conflict-set" - , runTest $ - let db = [ Right $ exAv "my-package" 1 [ExFix "other-package" 3] - , Left $ exInst "other-package" 2 "other-package-2.0.0.0" [] - , Left $ exInst "other-package" 1 "other-package-AbCdEfGhIj0123456789" [] ] - msg = "rejecting: other-package-2.0.0/installed-2.0.0.0, " - ++ "other-package-1.0.0/installed-AbCdEfGhIj0123456789 " - ++ "(conflict: my-package => other-package==3.0.0)" - in mkTest db "show full installed package ABI hash (issue #5892)" ["my-package"] $ - solverFailure (isInfixOf msg) ] ] where diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.cabal.out b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.cabal.out index 74ede341052..e91346a7b78 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.cabal.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/setup-external.cabal.out @@ -101,7 +101,7 @@ Warning: solver failed to find a solution: Could not resolve dependencies: [__0] trying: exe-0.1.0.0 (user goal) [__1] next goal: src (dependency of exe) -[__1] rejecting: src-/installed- (conflict: src => mylib==/installed-, src => mylib==/installed-) +[__1] rejecting: src-/installed-... (conflict: src => mylib==0.1.0.0/installed-0.1..., src => mylib==0.1.0.0/installed-0.1...) [__1] fail (backjumping, conflict set: exe, src) After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: exe (2), src (2) Trying configure anyway. diff --git a/cabal-testsuite/Test/Cabal/OutputNormalizer.hs b/cabal-testsuite/Test/Cabal/OutputNormalizer.hs index 31fef0f47bd..da57aa31e47 100644 --- a/cabal-testsuite/Test/Cabal/OutputNormalizer.hs +++ b/cabal-testsuite/Test/Cabal/OutputNormalizer.hs @@ -33,11 +33,13 @@ normalizeOutput nenv = . resub (posixRegexEscape (normalizerRoot nenv)) "/" . resub (posixRegexEscape (normalizerTmpDir nenv)) "/" . appEndo (F.fold (map (Endo . packageIdRegex) (normalizerKnownPackages nenv))) - -- Look for 0.1/installed-0d6uzW7Ubh1Fb4TB5oeQ3G + -- Look for foo-0.1/installed-0d6... -- These installed packages will vary depending on GHC version + -- Makes assumption that installed packages don't have numbers + -- in package name segment. -- Apply this before packageIdRegex, otherwise this regex doesn't match. - . resub "[0-9]+(\\.[0-9]+)*/installed-[A-Za-z0-9.+]+" - "/installed-" + . resub "([a-zA-Z]+(-[a-zA-Z])*)-[0-9]+(\\.[0-9]+)*/installed-[A-Za-z0-9.]+" + "\\1-/installed-..." -- Normalize architecture . resub (posixRegexEscape (display (normalizerPlatform nenv))) "" -- Some GHC versions are chattier than others