test: Added --jobs option

Default to the number of CPU cores, which seems about optimal
on my laptop. Using one more saves me 2 seconds actually.

Better packing of workers improves speed significantly.

In 2 tests runs, I saw segfaulting workers despite my attempt
to work around that issue. So detect when a worker does, and re-run it.

Removed installSignalHandlers again, because I was seeing an
error "lost signal due to full pipe", which I guess was somehow caused
by using it.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-03-16 14:42:07 -04:00
parent be31a8a3d2
commit 025c18128b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 77 additions and 24 deletions

10
Test.hs
View file

@ -11,13 +11,14 @@ module Test where
import Types.Test
import Types.RepoVersion
import Types.Concurrency
import Test.Framework
import Options.Applicative.Types
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck
import Options.Applicative (switch, long, help, internal)
import Options.Applicative (switch, long, short, help, internal, maybeReader, option)
import qualified Data.Map as M
import qualified Data.ByteString.Lazy.UTF8 as BU8
@ -90,7 +91,7 @@ import qualified Utility.Gpg
optParser :: Parser TestOptions
optParser = TestOptions
<$> snd (tastyParser (tests 1 False True mempty))
<$> snd (tastyParser (tests 1 False True (TestOptions mempty False False Nothing mempty)))
<*> switch
( long "keep-failures"
<> help "preserve repositories on test failure"
@ -99,6 +100,11 @@ optParser = TestOptions
( long "fakessh"
<> internal
)
<*> optional (option (maybeReader parseConcurrency)
( long "jobs"
<> short 'J'
<> help "number of concurrent jobs"
))
<*> cmdParams "non-options are for internal use only"
runner :: TestOptions -> IO ()