avoid splitting repo tests into too small parts around -J16

The initTests have to be run once per part, and a point of diminishing
returns can be reached where more work is being done to set up for 1 or
2 tests than to run them.

This is better than a hard cap of -J8 or so, because it lets other
things than these particular tests still be parallelized at -J16.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-11-07 14:44:51 -04:00
parent 5e6cb47bd8
commit 4f6c6114fb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 37 additions and 1 deletions

10
Test.hs
View file

@ -355,7 +355,15 @@ repoTests note numparts = map mk $ sep
mk l = testGroup groupname (initTests : map adddep l)
adddep = Test.Tasty.after AllSucceed (groupname ++ "." ++ initTestsName)
groupname = "Repo Tests " ++ note
sep = sep' (replicate numparts [])
sep l =
-- Avoid separating into parts that contain less than
-- 5 tests each. Since the tests depend on the
-- initTests, this avoids spending too much work running
-- the initTests once per part.
let numparts' = if length l `div` numparts > 5
then numparts
else length l `div` 5
in sep' (replicate numparts' []) l
sep' (p:ps) (l:ls) = sep' (ps++[l:p]) ls
sep' ps [] = ps
sep' [] _ = []