2015-05-03 01:27:48 +02:00
|
|
|
module Main where
|
|
|
|
|
2015-05-14 13:47:39 +02:00
|
|
|
import Data.List (isPrefixOf)
|
|
|
|
import System.Directory
|
|
|
|
import System.FilePath
|
2015-05-03 01:27:48 +02:00
|
|
|
import System.FilePath.Find
|
|
|
|
import Test.DocTest
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
|
|
|
files <- find always (extension ==? ".hs") "src"
|
2015-05-14 13:47:39 +02:00
|
|
|
cabalMacrosFile <- getCabalMacrosFile
|
2015-05-03 01:27:48 +02:00
|
|
|
doctest $ [ "-isrc"
|
|
|
|
, "-optP-include"
|
2015-05-14 13:47:39 +02:00
|
|
|
, "-optP" ++ cabalMacrosFile
|
2015-05-03 01:27:48 +02:00
|
|
|
, "-XOverloadedStrings"
|
|
|
|
, "-XFlexibleInstances"
|
|
|
|
, "-XMultiParamTypeClasses"
|
|
|
|
, "-XDataKinds"
|
|
|
|
, "-XTypeOperators"
|
|
|
|
] ++ files
|
|
|
|
|
2015-05-14 13:47:39 +02:00
|
|
|
getCabalMacrosFile :: IO FilePath
|
|
|
|
getCabalMacrosFile = do
|
|
|
|
contents <- getDirectoryContents "dist"
|
|
|
|
let rest = "build" </> "autogen" </> "cabal_macros.h"
|
|
|
|
return $ case filter ("dist-sandbox-" `isPrefixOf`) contents of
|
|
|
|
[x] -> "dist" </> x </> rest
|
|
|
|
[] -> "dist" </> rest
|
2015-05-16 03:14:24 +02:00
|
|
|
xs -> error $ "ran doctests with multiple dist/dist-sandbox-xxxxx's: \n"
|
|
|
|
++ show xs ++ "\nTry cabal clean"
|