Add doctests test suite.

This commit is contained in:
Pranay Sashank 2021-02-04 20:50:05 +05:30
parent 2c21267a6d
commit c88b23e119
4 changed files with 44 additions and 3 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ cabal.project.local
# Other
.log
_doctests/

View File

@ -1,6 +1,6 @@
module Main (main) where
import Distribution.Simple
import Distribution.Extra.Doctest (defaultMainAutoconfWithDoctests)
main :: IO ()
main = defaultMainWithHooks autoconfUserHooks
main = defaultMainAutoconfWithDoctests "doctests"

14
doctests.hs Normal file
View File

@ -0,0 +1,14 @@
module Main where
import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import System.Environment.Compat (unsetEnv)
import Test.DocTest (doctest)
main :: IO ()
main = do
traverse_ putStrLn args
unsetEnv "GHC_ENVIRONMENT"
doctest args
where
args = flags ++ ["-outputdir=./_doctests/", "-fobject-code"] ++ pkgs ++ module_sources

View File

@ -91,7 +91,7 @@ maintainer: streamly@composewell.com
copyright: 2017 Composewell Technologies
category: Control, Concurrency, Streaming, Reactivity
stability: Experimental
build-type: Configure
build-type: Custom
extra-source-files:
.circleci/config.yml
@ -238,6 +238,16 @@ flag opt
manual: True
default: True
flag doctests
description: Build doctests test suite
manual: True
default: False
custom-setup
setup-depends:
base >= 4 && <5,
cabal-doctest >= 1 && <1.1
-------------------------------------------------------------------------------
-- Common stanzas
-------------------------------------------------------------------------------
@ -570,3 +580,19 @@ library
-- tests fail
if flag(dev) && flag(inspection)
build-depends: inspection-and-dev-flags-cannot-be-used-together
test-suite doctests
type: exitcode-stdio-1.0
main-is: doctests.hs
if flag(doctests)
build-depends:
base
, base-compat >=0.10.5 && <0.12
, doctest >=0.15 && <0.18
, streamly
else
buildable: False
ghc-options: -Wall -threaded
hs-source-dirs: .
default-language: Haskell2010