Skip to content

Commit 6f0cbe0

Browse files
committed
More asserts on 'completed'
This assert would have more directly pinpointed the InstallPlan invariant that was broken in haskell#4986. Signed-off-by: Edward Z. Yang <[email protected]>
1 parent cf8c9a7 commit 6f0cbe0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cabal-install/Distribution/Client/InstallPlan.hs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ import Distribution.Solver.Types.SolverId
8989
import Distribution.Solver.Types.InstSolverPackage
9090

9191
import Distribution.Utils.LogProgress
92+
import Distribution.Client.Utils.Assertion
93+
import Distribution.Compat.Stack
9294

9395
-- TODO: Need this when we compute final UnitIds
9496
-- import qualified Distribution.Simple.Configure as Configure
@@ -102,6 +104,7 @@ import Distribution.Pretty
102104
import qualified Distribution.Compat.Graph as Graph
103105
import Distribution.Compat.Graph (Graph, IsNode(..))
104106
import Distribution.Compat.Binary (Binary(..))
107+
import Distribution.Utils.Generic
105108
import GHC.Generics
106109
import Data.Typeable
107110
import Control.Monad
@@ -629,19 +632,26 @@ isInstalled _ = False
629632
-- process), along with the updated 'Processing' state.
630633
--
631634
completed :: (IsUnit ipkg, IsUnit srcpkg)
632-
=> GenericInstallPlan ipkg srcpkg
635+
=> WithCallStack (GenericInstallPlan ipkg srcpkg
633636
-> Processing -> UnitId
634-
-> ([GenericReadyPackage srcpkg], Processing)
637+
-> ([GenericReadyPackage srcpkg], Processing))
635638
completed plan (Processing processingSet completedSet failedSet) pkgid =
636-
assert (pkgid `Set.member` processingSet) $
639+
pprAssert (pkgid `Set.member` processingSet)
640+
(text "Completed" <+> pretty pkgid <+> text "was not member of processing set:" $$
641+
pretty (Set.toList processingSet) $$
642+
text "Already completed:" <+> pretty (Set.toList completedSet) $$
643+
text "Failed:" <+> pretty (Set.toList failedSet)) $
637644
assert (processingInvariant plan processing') $
645+
pprAssert (length (ordNub newlyReadyKeys) == length newlyReadyKeys)
646+
(text "Duplicate entry in newly-ready tasks:" <+> pretty newlyReadyKeys) $
638647

639648
( map asReadyPackage newlyReady
640649
, processing' )
641650
where
642651
completedSet' = Set.insert pkgid completedSet
643652

644653
-- each direct reverse dep where all direct deps are completed
654+
newlyReadyKeys = map nodeKey newlyReady
645655
newlyReady = [ dep
646656
| dep <- revDirectDeps plan pkgid
647657
, all ((`Set.member` completedSet') . nodeKey)

0 commit comments

Comments
 (0)