Commit 1cff0d4e authored by Adam Vogt's avatar Adam Vogt

add doctest runner

parent f159fca4
......@@ -89,3 +89,10 @@ executable IHaskell
here,
system-filepath,
text ==0.11.*
Test-Suite doctests
Type: exitcode-stdio-1.0
Ghc-Options: -threaded
Main-Is: rundoctests.hs
Build-Depends: base, doctest >= 0.8, process
import System.Process
import System.Exit
import System.IO
import Test.DocTest
import Data.Char
import System.Environment
-- | tests that all the >>> comments are followed by correct output. Easiest is to
--
-- > cabal test
--
-- or
--
-- > runghc examples/rundoctests.hs
--
-- or
--
-- > runghc examples/rundoctests.hs Data/HList/File1.hs Data/HList/File2.hs
--
-- you need Cabal >= 1.18 since that's around when cabal repl got added.
main = do
as <- getArgs
o <- readProcess
"cabal" ["repl","--ghc-options","-v0 -w"]
":show packages\n:show language"
let flags = words $ unlines $ filter ((=="-") . take 1 . dropWhile isSpace)
$ lines o
let files = case as of
[] -> ["Main.hs"]
_ -> as
doctest $ "-i.": "-idist/build/autogen":
"-optP-include":
"-optPdist/build/autogen/cabal_macros.h" :
"-Idist/build/autogen" : "-w":
files ++ flags
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment