speed up --pattern

The splitting of the tests into parts for parallelism made --pattern
do extra work, because init tests have to be run for each part, but
many of the parts are empty.

For example, git-annex test --pattern '/move (ssh remote)/'
took 12 seconds to run before. This improves the runtime to 4 seconds.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-12-07 13:46:16 -04:00
parent b7ba6dfe48
commit ac77aa40e7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 13 additions and 5 deletions

View file

@ -749,7 +749,12 @@ parallelTestRunner' numjobs opts mkts
-- 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
--
-- When there is a pattern, splitting into parts will cause
-- extra work.
numparts = if haspattern
then 1
else numjobs * 2
worker rs nvar a = do
(n, m) <- atomically $ do
@ -814,15 +819,16 @@ parallelTestRunner' numjobs opts mkts
, exitFailure
)
tastyopts = case lookupOption (tastyOptionSet opts) of
(haspattern, 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
(True, setOption (TestPattern (Just (TP.Or p (TP.ERE initTestsName))))
(tastyOptionSet opts))
TestPattern Nothing ->
(False, tastyOptionSet opts)
topLevelTestGroup :: [TestTree] -> TestTree
topLevelTestGroup = testGroup "Tests"

View file

@ -14,4 +14,6 @@ This will limit the test suite to only running the that test:
I have that repeating locally in a loop, in case it's just something that
happens every 1000 test runs or something like that.
(I've patched git-annex to speed up the above command 400%.)
"""]]