on master help sign in
Add doctests test suite.
c88b23ePranay Sashank
.gitignore+1
@@ -14,3 +14,4 @@ cabal.project.local
14
14
15# Other
15# Other
16.log
16.log
17+_doctests/
Setup.hs+2−2
@@ -1,6 +1,6 @@
1module Main (main) where
1module Main (main) where
2
2
3−import Distribution.Simple
3+import Distribution.Extra.Doctest (defaultMainAutoconfWithDoctests)
4
4
5main :: IO ()
5main :: IO ()
6−main = defaultMainWithHooks autoconfUserHooks
6+main = defaultMainAutoconfWithDoctests "doctests"
doctests.hsnew file+14
@@ -0,0 +1,14 @@
1+module Main where
2+
3+import Build_doctests (flags, pkgs, module_sources)
4+import Data.Foldable (traverse_)
5+import System.Environment.Compat (unsetEnv)
6+import Test.DocTest (doctest)
7+
8+main :: IO ()
9+main = do
10+ traverse_ putStrLn args
11+ unsetEnv "GHC_ENVIRONMENT"
12+ doctest args
13+ where
14+ args = flags ++ ["-outputdir=./_doctests/", "-fobject-code"] ++ pkgs ++ module_sources
streamly.cabal+27−1
@@ -91,7 +91,7 @@ maintainer: streamly@composewell.com
91copyright: 2017 Composewell Technologies
91copyright: 2017 Composewell Technologies
92category: Control, Concurrency, Streaming, Reactivity
92category: Control, Concurrency, Streaming, Reactivity
93stability: Experimental
93stability: Experimental
94−build-type: Configure
94+build-type: Custom
95
95
96extra-source-files:
96extra-source-files:
97 .circleci/config.yml
97 .circleci/config.yml
@@ -238,6 +238,16 @@ flag opt
238 manual: True
238 manual: True
239 default: True
239 default: True
240
240
241+flag doctests
242+ description: Build doctests test suite
243+ manual: True
244+ default: False
245+
246+custom-setup
247+ setup-depends:
248+ base >= 4 && <5,
249+ cabal-doctest >= 1 && <1.1
250+
241-------------------------------------------------------------------------------
251-------------------------------------------------------------------------------
242-- Common stanzas
252-- Common stanzas
243-------------------------------------------------------------------------------
253-------------------------------------------------------------------------------
@@ -570,3 +580,19 @@ library
570 -- tests fail
580 -- tests fail
571 if flag(dev) && flag(inspection)
581 if flag(dev) && flag(inspection)
572 build-depends: inspection-and-dev-flags-cannot-be-used-together
582 build-depends: inspection-and-dev-flags-cannot-be-used-together
583+
584+test-suite doctests
585+ type: exitcode-stdio-1.0
586+ main-is: doctests.hs
587+ if flag(doctests)
588+ build-depends:
589+ base
590+ , base-compat >=0.10.5 && <0.12
591+ , doctest >=0.15 && <0.18
592+ , streamly
593+ else
594+ buildable: False
595+
596+ ghc-options: -Wall -threaded
597+ hs-source-dirs: .
598+ default-language: Haskell2010