Skip to content

Commit

Permalink
lib: doctests: add --verbose and --slow flags to executable
Browse files Browse the repository at this point in the history
--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)
  • Loading branch information
simonmichael committed Aug 3, 2018
1 parent 8a4fb59 commit ed93807
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions hledger-lib/package.yaml
Expand Up @@ -156,6 +156,7 @@ tests:
dependencies:
- Glob >=0.7
- doctest >=0.8
# doctest >=0.16.0 needed to show verbose progress output
# doctest with ghc 8.4 on mac requires a workaround:
# ~$ 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
Expand Down
8 changes: 7 additions & 1 deletion hledger-lib/tests/doctests.hs
@@ -1,14 +1,20 @@
{-# LANGUAGE PackageImports #-}

import Data.List
import System.Environment
import "Glob" System.FilePath.Glob
import Test.DocTest

main = do
args <- getArgs
fs1 <- glob "Hledger/**/*.hs"
fs2 <- glob "Text/**/*.hs"
--fs3 <- glob "other/ledger-parse/**/*.hs"
let fs = filter (not . isInfixOf "/.") $ ["Hledger.hs"] ++ fs1 ++ fs2
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

0 comments on commit ed93807

Please sign in to comment.