From ed93807ee5b9b02f3db15c2adf5f5ba193bde9b5 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 3 Aug 2018 18:09:52 +0100 Subject: [PATCH] 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) --- hledger-lib/package.yaml | 1 + hledger-lib/tests/doctests.hs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hledger-lib/package.yaml b/hledger-lib/package.yaml index 4e521fe41..6f89f0e1d 100644 --- a/hledger-lib/package.yaml +++ b/hledger-lib/package.yaml @@ -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 diff --git a/hledger-lib/tests/doctests.hs b/hledger-lib/tests/doctests.hs index c08e0dabe..83d17dd9a 100644 --- a/hledger-lib/tests/doctests.hs +++ b/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