mirror of
https://github.com/ilyakooo0/servant-quickcheck.git
synced 2024-09-11 18:37:09 +03:00
45 lines
1.4 KiB
Haskell
45 lines
1.4 KiB
Haskell
module Main where
|
|
|
|
import Data.List (isPrefixOf)
|
|
import System.Directory
|
|
import System.FilePath
|
|
import System.FilePath.Find
|
|
import Test.DocTest
|
|
|
|
main :: IO ()
|
|
main = do
|
|
files <- find always (extension ==? ".hs") "src"
|
|
mCabalMacrosFile <- getCabalMacrosFile
|
|
doctest $ "-isrc" : "-Iinclude" :
|
|
(maybe [] (\ f -> ["-optP-include", "-optP" ++ f]) mCabalMacrosFile) ++
|
|
"-XOverloadedStrings" :
|
|
"-XDeriveFunctor" :
|
|
"-XFlexibleInstances" :
|
|
"-XFlexibleContexts" :
|
|
"-XMultiParamTypeClasses" :
|
|
"-XDataKinds" :
|
|
"-XTypeOperators" :
|
|
"-XGADTs" :
|
|
files
|
|
|
|
getCabalMacrosFile :: IO (Maybe FilePath)
|
|
getCabalMacrosFile = do
|
|
exists <- doesDirectoryExist "dist"
|
|
if exists
|
|
then do
|
|
contents <- getDirectoryContents "dist"
|
|
let rest = "build" </> "autogen" </> "cabal_macros.h"
|
|
whenExists $ case filter ("dist-sandbox-" `isPrefixOf`) contents of
|
|
[x] -> "dist" </> x </> rest
|
|
[] -> "dist" </> rest
|
|
xs -> error $ "ran doctests with multiple dist/dist-sandbox-xxxxx's: \n"
|
|
++ show xs ++ "\nTry cabal clean"
|
|
else return Nothing
|
|
where
|
|
whenExists :: FilePath -> IO (Maybe FilePath)
|
|
whenExists file = do
|
|
exists <- doesFileExist file
|
|
return $ if exists
|
|
then Just file
|
|
else Nothing
|