on master help sign in
Add doctests test suite.
commitc88b23e119e78bc268097f6dc1c837562d443d16 authorPranay Sashank <pranaysashank@composewell.com> dateThu 4 Feb 2021, 20:50 (6 years ago) parent2c21267
4 files changed+44−3
.gitignore+1 Setup.hs+2−2 doctests.hs+14 streamly.cabal+27−1
.gitignore+1
@@ -14,3 +14,4 @@ cabal.project.local
1414
1515# Other
1616.log
17+_doctests/
Setup.hs+2−2
@@ -1,6 +1,6 @@
11module Main (main) where
22
3−import Distribution.Simple
3+import Distribution.Extra.Doctest (defaultMainAutoconfWithDoctests)
44
55main :: 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
9191copyright: 2017 Composewell Technologies
9292category: Control, Concurrency, Streaming, Reactivity
9393stability: Experimental
94−build-type: Configure
94+build-type: Custom
9595
9696extra-source-files:
9797 .circleci/config.yml
@@ -238,6 +238,16 @@ flag opt
238238 manual: True
239239 default: True
240240
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+
241251-------------------------------------------------------------------------------
242252-- Common stanzas
243253-------------------------------------------------------------------------------
@@ -570,3 +580,19 @@ library
570580 -- tests fail
571581 if flag(dev) && flag(inspection)
572582 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