From 28c4051e3dfd53a5bce65a3dd3ac05504fe0afd4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 18 May 2023 11:19:59 -0400 Subject: [PATCH] add test summary with number of parts and time Sponsored-by: Brock Spratlen on Patreon --- Test.hs | 4 ++-- Test/Framework.hs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Test.hs b/Test.hs index 5352351a8b..f55d9b8dc3 100644 --- a/Test.hs +++ b/Test.hs @@ -128,7 +128,7 @@ runner :: TestOptions -> IO () runner opts = parallelTestRunner opts tests tests :: Int -> Bool -> Bool -> TestOptions -> [TestTree] -tests n crippledfilesystem adjustedbranchok opts = +tests numparts crippledfilesystem adjustedbranchok opts = properties : withTestMode remotetestmode testRemotes : concatMap mkrepotests testmodes @@ -147,7 +147,7 @@ tests n crippledfilesystem adjustedbranchok opts = | otherwise = Nothing mkrepotests (d, te) = map (\uts -> withTestMode te uts) - (repoTests d n) + (repoTests d numparts) properties :: TestTree properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck" $ diff --git a/Test/Framework.hs b/Test/Framework.hs index 7c2316c238..7d073e7468 100644 --- a/Test/Framework.hs +++ b/Test/Framework.hs @@ -23,6 +23,7 @@ import Control.Concurrent.STM import System.Environment (getArgs) import System.Console.Concurrent import System.Console.ANSI +import Data.Time.Clock import GHC.Conc import System.IO.Unsafe (unsafePerformIO) import System.PosixCompat.Files (isSymbolicLink, isRegularFile, fileMode, unionFileModes, ownerWriteMode) @@ -63,6 +64,7 @@ import qualified Utility.Exception import qualified Utility.ThreadScheduler import qualified Utility.Tmp.Dir import qualified Utility.Metered +import qualified Utility.HumanTime import qualified Command.Uninit -- Run a process. The output and stderr is captured, and is only @@ -799,11 +801,20 @@ parallelTestRunner' numjobs opts mkts (_, _, _, pid) <- createProcessConcurrent p waitForProcess pid nvar <- newTVarIO (1, length ts) + starttime <- getCurrentTime exitcodes <- forConcurrently [1..numjobs] $ \_ -> worker [] nvar runone unless (keepFailuresOption opts) finalCleanup + duration <- Utility.HumanTime.durationSince starttime case nub (filter (/= ExitSuccess) (concat exitcodes)) of - [] -> exitSuccess + [] -> do + putStrLn "" + putStrLn $ "All tests succeeded. (Ran " + ++ show (length ts) + ++ " test groups in " + ++ Utility.HumanTime.fromDuration duration + ++ ")" + exitSuccess [ExitFailure 1] -> do putStrLn " (Failures above could be due to a bug in git-annex, or an incompatibility" putStrLn " with utilities, such as git, installed on this system.)"