Skip to content

Commit 0512ce1

Browse files
committed
Doctest running via doctest-parallel
`doctest-parallel` (13sec) is faster than plain `doctest` (30sec). By default, `doctest-parallel` only runs the tests for exported functions, but this can be worked around if necessary (see docs).
1 parent e8cf5ec commit 0512ce1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

hackage-server.cabal

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,12 @@ test-suite HashTests
564564
, tasty ^>= 1.4
565565
, tasty-hunit ^>= 0.10
566566

567+
test-suite DocTests
568+
import: test-defaults
569+
570+
type: exitcode-stdio-1.0
571+
main-is: DocTestMain.hs
572+
573+
build-depends:
574+
, lib-server
575+
, doctest-parallel ^>= 0.2.1

tests/DocTestMain.hs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- | `doctest-parallel` runner for `hackage-server` library.
2+
module Main where
3+
4+
import Data.List
5+
( isPrefixOf )
6+
import System.Environment
7+
( getArgs )
8+
9+
import Distribution.ModuleName
10+
( components )
11+
12+
import Test.DocTest
13+
( mainFromLibrary )
14+
import Test.DocTest.Helpers
15+
( Library(..), extractSpecificCabalLibrary, findCabalPackage )
16+
17+
-- | Doctest @hackage-server:lib-server@.
18+
main :: IO ()
19+
main = do
20+
args <- getArgs
21+
pkg <- findCabalPackage "hackage-server"
22+
-- Need to give the library name, otherwise the parser does not find it.
23+
lib <- extractSpecificCabalLibrary (Just "lib-server") pkg
24+
-- Need to filter out the @Paths_*@ modules, as they are not found by doctest-parallel.
25+
let f = not . ("Paths_" `isPrefixOf`) . head . components
26+
let lib' = lib{ libModules = filter f $ libModules lib }
27+
mainFromLibrary lib' args

0 commit comments

Comments
 (0)