lib: doctests: add --verbose and --slow flags to executable

--slow turns off doctest's --fast flag, which skips reloading between
  tests.
--verbose shows progress output as tests are run, if doctest 0.16.0+
  is installed (and I believe will be harmless otherwise)
This commit is contained in:
Simon Michael 2018-08-03 18:09:52 +01:00
parent 8a4fb59aaa
commit ed93807ee5
2 changed files with 8 additions and 1 deletions

View File

@ -156,6 +156,7 @@ tests:
dependencies: dependencies:
- Glob >=0.7 - Glob >=0.7
- doctest >=0.8 - doctest >=0.8
# doctest >=0.16.0 needed to show verbose progress output
# doctest with ghc 8.4 on mac requires a workaround: # doctest with ghc 8.4 on mac requires a workaround:
# ~$ locate HSinteger-gmp-1.0.2.0.o # ~$ locate HSinteger-gmp-1.0.2.0.o
# /Users/simon/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.2/integer-gmp-1.0.2.0/HSinteger-gmp-1.0.2.0.o # /Users/simon/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.2/integer-gmp-1.0.2.0/HSinteger-gmp-1.0.2.0.o

View File

@ -1,14 +1,20 @@
{-# LANGUAGE PackageImports #-} {-# LANGUAGE PackageImports #-}
import Data.List import Data.List
import System.Environment
import "Glob" System.FilePath.Glob import "Glob" System.FilePath.Glob
import Test.DocTest import Test.DocTest
main = do main = do
args <- getArgs
fs1 <- glob "Hledger/**/*.hs" fs1 <- glob "Hledger/**/*.hs"
fs2 <- glob "Text/**/*.hs" fs2 <- glob "Text/**/*.hs"
--fs3 <- glob "other/ledger-parse/**/*.hs" --fs3 <- glob "other/ledger-parse/**/*.hs"
let fs = filter (not . isInfixOf "/.") $ ["Hledger.hs"] ++ fs1 ++ fs2 let fs = filter (not . isInfixOf "/.") $ ["Hledger.hs"] ++ fs1 ++ fs2
doctest $ doctest $
"--fast" : -- https://github.com/sol/doctest#a-note-on-performance -- show verbose progress output
(if "--verbose" `elem` args then ("--verbose" :) else id) $
-- don't reload environment per test (opposite of doctest's --fast,
-- https://github.com/sol/doctest#a-note-on-performance)
(if "--slow" `elem` args then id else ("--fast" :)) $
fs fs