@@ -279,7 +279,21 @@ executePlan' plan ee = do
279279 (planTasks plan)
280280 (planFinals plan)
281281 threads <- asks $ configJobs . getConfig
282- errs <- liftIO $ runActions threads actions
282+ errs <- liftIO $ runActions threads actions $ \ doneVar -> do
283+ let total = length actions
284+ loop prev
285+ | prev == total =
286+ runInBase $ $ logStickyDone (" Completed all " <> T. pack (show total) <> " actions." )
287+ | otherwise = do
288+ runInBase $ $ logSticky (" Progress: " <> T. pack (show prev) <> " /" <> T. pack (show total))
289+ done <- atomically $ do
290+ done <- readTVar doneVar
291+ check $ done /= prev
292+ return done
293+ loop done
294+ if total > 1
295+ then loop 0
296+ else return ()
283297 unless (null errs) $ throwM $ ExecutionFailure errs
284298
285299toActions :: M env m
@@ -303,15 +317,15 @@ toActions runInBase ee (mbuild, mfinal) =
303317 ]
304318 afinal =
305319 case (,) <$> mfinal <*> mfunc of
306- Nothing -> []
307- Just (task@ Task {.. }, func) ->
320+ Just (task@ Task {.. }, (func, checkTask)) | checkTask task ->
308321 [ Action
309322 { actionId = ActionId taskProvides ATFinal
310323 , actionDeps = addBuild taskProvides $
311324 (Set. map (\ ident -> ActionId ident ATBuild ) (tcoMissing taskConfigOpts))
312325 , actionDo = \ ac -> runInBase $ func ac ee task
313326 }
314327 ]
328+ _ -> []
315329 where
316330 addBuild ident =
317331 case mbuild of
@@ -321,22 +335,31 @@ toActions runInBase ee (mbuild, mfinal) =
321335 mfunc =
322336 case boptsFinalAction $ eeBuildOpts ee of
323337 DoNothing -> Nothing
324- DoTests -> Just singleTest
325- DoBenchmarks -> Just singleBench
326- DoHaddock -> Just singleHaddock
338+ DoTests -> Just (singleTest, checkTest)
339+ DoBenchmarks -> Just (singleBench, checkBench)
340+ DoHaddock -> Just (singleHaddock, const True )
341+
342+ checkTest task =
343+ case taskType task of
344+ TTLocal lp -> not $ Set. null $ packageTests $ lpPackage lp
345+ _ -> assert False False
346+
347+ checkBench task =
348+ case taskType task of
349+ TTLocal lp -> not $ Set. null $ packageBenchmarks $ lpPackage lp
350+ _ -> assert False False
327351
328352-- | Ensure that the configuration for the package matches what is given
329353ensureConfig :: M env m
330354 => Path Abs Dir -- ^ package directory
331- -> ActionContext
332355 -> ExecuteEnv
333356 -> Task
334357 -> m () -- ^ announce
335358 -> (Bool -> [String ] -> m () ) -- ^ cabal
336359 -> Path Abs File -- ^ .cabal file
337360 -> [Text ]
338361 -> m (ConfigCache , Bool )
339- ensureConfig pkgDir ac ExecuteEnv {.. } Task {.. } announce cabal cabalfp extra = do
362+ ensureConfig pkgDir ExecuteEnv {.. } Task {.. } announce cabal cabalfp extra = do
340363 -- Determine the old and new configuration in the local directory, to
341364 -- determine if we need to reconfigure.
342365 mOldConfigCache <- tryGetConfigCache pkgDir
@@ -363,8 +386,6 @@ ensureConfig pkgDir ac ExecuteEnv {..} Task {..} announce cabal cabalfp extra =
363386 || mOldCabalMod /= Just newCabalMod
364387 when needConfig $ withMVar eeConfigureLock $ \ _ -> do
365388 deleteCaches pkgDir
366- withMVar eeInstallLock $ \ () ->
367- $ logSticky (" Progress: " <> T. pack (show (acCompleted ac)) <> " /" <> T. pack (show (acTotalActions ac)))
368389 announce
369390 cabal False $ " configure" : map T. unpack configOpts
370391 $ logDebug $ T. pack $ show configOpts
@@ -506,7 +527,7 @@ singleBuild :: M env m
506527 -> m ()
507528singleBuild ac@ ActionContext {.. } ee@ ExecuteEnv {.. } task@ Task {.. } =
508529 withSingleContext ac ee task $ \ package cabalfp pkgDir cabal announce console _mlogFile -> do
509- (cache, _neededConfig) <- ensureConfig pkgDir ac ee task (announce " configure" ) cabal cabalfp []
530+ (cache, _neededConfig) <- ensureConfig pkgDir ee task (announce " configure" ) cabal cabalfp []
510531
511532 fileModTimes <- getPackageFileModTimes package cabalfp
512533 writeBuildCache pkgDir fileModTimes
@@ -518,11 +539,6 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} =
518539 withMVar eeInstallLock $ \ () -> do
519540 announce " install"
520541 cabal False [" install" ]
521- unless (acTotalActions == 1 ) $ do
522- let done' = acCompleted + 1
523- $ logSticky (" Progress: " <> T. pack (show done') <> " /" <> T. pack (show acTotalActions))
524- when (done' == acTotalActions)
525- ($ logStickyDone (" Completed all " <> T. pack (show acTotalActions) <> " packages." ))
526542
527543 let pkgDbs =
528544 case taskLocation task of
@@ -549,9 +565,8 @@ singleTest :: M env m
549565 -> Task
550566 -> m ()
551567singleTest ac ee task =
552- withSingleContext ac ee task $ \ package cabalfp pkgDir cabal announce console mlogFile ->
553- unless (Set. null $ packageTests package) $ do
554- (_cache, neededConfig) <- ensureConfig pkgDir ac ee task (announce " configure (test)" ) cabal cabalfp [" --enable-tests" ]
568+ withSingleContext ac ee task $ \ package cabalfp pkgDir cabal announce console mlogFile -> do
569+ (_cache, neededConfig) <- ensureConfig pkgDir ee task (announce " configure (test)" ) cabal cabalfp [" --enable-tests" ]
555570 config <- asks getConfig
556571
557572 let needBuild = neededConfig ||
@@ -622,9 +637,8 @@ singleBench :: M env m
622637 -> Task
623638 -> m ()
624639singleBench ac ee task =
625- withSingleContext ac ee task $ \ package cabalfp pkgDir cabal announce console _mlogFile ->
626- unless (Set. null $ packageBenchmarks package) $ do
627- (_cache, neededConfig) <- ensureConfig pkgDir ac ee task (announce " configure (benchmarks)" ) cabal cabalfp [" --enable-benchmarks" ]
640+ withSingleContext ac ee task $ \ _package cabalfp pkgDir cabal announce console _mlogFile -> do
641+ (_cache, neededConfig) <- ensureConfig pkgDir ee task (announce " configure (benchmarks)" ) cabal cabalfp [" --enable-benchmarks" ]
628642
629643 let needBuild = neededConfig ||
630644 (case taskType task of
0 commit comments