From bb4b8a1740bedbfa40fa0d3e67b993891b406331 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus <oleg.grenrus@iki.fi> Date: Sat, 2 Sep 2017 01:34:30 +0300 Subject: [PATCH] Add make doctest [ci skip] This is poor man doctest. Prerequisites: - `doctest` executable is in `$PATH`, compiled with GHC used to new-build the Cabal - `.ghc.environment` file is generated As GHC picks up dependencies from `.ghc.environment` file, a simple `doctest MODULES` works. As you see, I had a bug in doctests. For now, I don't add this to CI, as it's enough to run doctests occasionally (there are only 4 examples atm). --- Cabal/Distribution/Compat/Newtype.hs | 2 +- Cabal/Distribution/Verbosity.hs | 5 +++++ Makefile | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cabal/Distribution/Compat/Newtype.hs b/Cabal/Distribution/Compat/Newtype.hs index 47958eb77f..e45e97cf92 100644 --- a/Cabal/Distribution/Compat/Newtype.hs +++ b/Cabal/Distribution/Compat/Newtype.hs @@ -55,7 +55,7 @@ ala pa hof = alaf pa hof id -- | -- -- >>> alaf Sum foldMap length ["cabal", "install"] --- 11 +-- 12 -- -- /Note:/ as with 'ala', the user supplied function for the newtype is /ignored/. alaf :: (Newtype n o, Newtype n' o') => (o -> n) -> ((a -> n) -> b -> n') -> (a -> o) -> (b -> o') diff --git a/Cabal/Distribution/Verbosity.hs b/Cabal/Distribution/Verbosity.hs index 8b13d42e2e..f6df3f54fc 100644 --- a/Cabal/Distribution/Verbosity.hs +++ b/Cabal/Distribution/Verbosity.hs @@ -291,3 +291,8 @@ isVerboseTimestamp = isVerboseFlag VTimestamp -- | Helper function for flag testing functions. isVerboseFlag :: VerbosityFlag -> Verbosity -> Bool isVerboseFlag flag = (Set.member flag) . vFlags + +-- $setup +-- >>> import Test.QuickCheck (Arbitrary (..), arbitraryBoundedEnum) +-- >>> instance Arbitrary VerbosityLevel where arbitrary = arbitraryBoundedEnum +-- >>> instance Arbitrary Verbosity where arbitrary = fmap mkVerbosity arbitrary diff --git a/Makefile b/Makefile index 47cc2dc0c1..9d90f05c21 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : all lexer lib exe +.PHONY : all lexer lib exe doctest LEXER_HS:=Cabal/Distribution/Parsec/Lexer.hs @@ -14,3 +14,6 @@ lib : $(LEXER_HS) exe : $(LEXER_HS) cabal new-build --enable-tests cabal + +doctest : + doctest --fast Cabal/Distribution Cabal/Language -- GitLab