fix git-annex test -p
test: When limiting tests to run with -p, work around tasty limitation by automatically including dependent tests. This fixes a reversion because it didn't used to use dependencies and forced tasty to run the init tests first. That changed when parallelizing the test suite. It will sometimes do a little more work than strictly required, because it adds init tests deps when limited to eg quickcheck tests, which don't depend on them. But this only adds a few seconds work. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
478ed28f98
commit
85f9193167
4 changed files with 37 additions and 13 deletions
|
@ -15,6 +15,7 @@ import Test.Tasty.HUnit
|
|||
import Test.Tasty.Options
|
||||
import Test.Tasty.Ingredients.Rerun
|
||||
import Test.Tasty.Ingredients.ConsoleReporter
|
||||
import qualified Test.Tasty.Patterns.Types as TP
|
||||
import Options.Applicative.Types
|
||||
import Control.Concurrent
|
||||
import Control.Concurrent.Async
|
||||
|
@ -724,10 +725,12 @@ parallelTestRunner' numjobs opts mkts
|
|||
| otherwise = go =<< Utility.Env.getEnv subenv
|
||||
where
|
||||
subenv = "GIT_ANNEX_TEST_SUBPROCESS"
|
||||
|
||||
-- Make more parts than there are jobs, because some parts
|
||||
-- are larger, and this allows the smaller parts to be packed
|
||||
-- in more efficiently, speeding up the test suite overall.
|
||||
numparts = numjobs * 2
|
||||
|
||||
worker rs nvar a = do
|
||||
(n, m) <- atomically $ do
|
||||
(n, m) <- readTVar nvar
|
||||
|
@ -738,6 +741,7 @@ parallelTestRunner' numjobs opts mkts
|
|||
else do
|
||||
r <- a n
|
||||
worker (r:rs) nvar a
|
||||
|
||||
go Nothing = withConcurrentOutput $ do
|
||||
ensuredir tmpdir
|
||||
crippledfilesystem <- fst <$> Annex.Init.probeCrippledFileSystem'
|
||||
|
@ -753,7 +757,7 @@ parallelTestRunner' numjobs opts mkts
|
|||
args <- getArgs
|
||||
pp <- Annex.Path.programPath
|
||||
termcolor <- hSupportsANSIColor stdout
|
||||
let ps = if useColor (lookupOption (tastyOptionSet opts)) termcolor
|
||||
let ps = if useColor (lookupOption tastyopts) termcolor
|
||||
then "--color=always":args
|
||||
else "--color=never":args
|
||||
let runone n = do
|
||||
|
@ -783,16 +787,29 @@ parallelTestRunner' numjobs opts mkts
|
|||
Just (n, crippledfilesystem, adjustedbranchok) -> setTestEnv $ do
|
||||
let ts = mkts numparts crippledfilesystem adjustedbranchok opts
|
||||
let t = topLevelTestGroup [ ts !! (n - 1) ]
|
||||
case tryIngredients ingredients (tastyOptionSet opts) t of
|
||||
case tryIngredients ingredients tastyopts t of
|
||||
Nothing -> error "No tests found!?"
|
||||
Just act -> ifM act
|
||||
( exitSuccess
|
||||
, exitFailure
|
||||
)
|
||||
|
||||
tastyopts = case lookupOption (tastyOptionSet opts) of
|
||||
-- Work around limitation of tasty; when tests to run
|
||||
-- are limited to a pattern, it does not include their
|
||||
-- dependencies. So, add another pattern including the
|
||||
-- init tests, which are a dependency of most tests.
|
||||
TestPattern (Just p) ->
|
||||
setOption (TestPattern (Just (TP.Or p (TP.ERE initTestsName))))
|
||||
(tastyOptionSet opts)
|
||||
TestPattern Nothing -> tastyOptionSet opts
|
||||
|
||||
topLevelTestGroup :: [TestTree] -> TestTree
|
||||
topLevelTestGroup = testGroup "Tests"
|
||||
|
||||
initTestsName :: String
|
||||
initTestsName = "Init Tests"
|
||||
|
||||
tastyParser :: [TestTree] -> ([String], Parser Test.Tasty.Options.OptionSet)
|
||||
#if MIN_VERSION_tasty(1,3,0)
|
||||
tastyParser ts = go
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue