diff --git a/.gitignore b/.gitignore index de16e47a..94a7b5d1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ cabal.config *.aux *.hp Setup +.stack-work diff --git a/servant-js/servant-js.cabal b/servant-js/servant-js.cabal index 2fa38e0c..24e3b31d 100644 --- a/servant-js/servant-js.cabal +++ b/servant-js/servant-js.cabal @@ -80,7 +80,7 @@ test-suite spec , lens , servant-js , servant - , hspec >= 2.0 + , hspec >= 2.1.8 , hspec-expectations , language-ecmascript >= 0.16 default-language: Haskell2010 diff --git a/servant-server/test/Doctests.hs b/servant-server/test/Doctests.hs index 71d1d2c2..0227abc0 100644 --- a/servant-server/test/Doctests.hs +++ b/servant-server/test/Doctests.hs @@ -9,23 +9,33 @@ import Test.DocTest main :: IO () main = do files <- find always (extension ==? ".hs") "src" - cabalMacrosFile <- getCabalMacrosFile - doctest $ [ "-isrc" - , "-optP-include" - , "-optP" ++ cabalMacrosFile - , "-XOverloadedStrings" - , "-XFlexibleInstances" - , "-XMultiParamTypeClasses" - , "-XDataKinds" - , "-XTypeOperators" - ] ++ files + mCabalMacrosFile <- getCabalMacrosFile + doctest $ "-isrc" : + (maybe [] (\ f -> ["-optP-include", "-optP" ++ f]) mCabalMacrosFile) ++ + "-XOverloadedStrings" : + "-XFlexibleInstances" : + "-XMultiParamTypeClasses" : + "-XDataKinds" : + "-XTypeOperators" : + files -getCabalMacrosFile :: IO FilePath +getCabalMacrosFile :: IO (Maybe 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 - xs -> error $ "ran doctests with multiple dist/dist-sandbox-xxxxx's: \n" - ++ show xs ++ "\nTry cabal clean" + 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 diff --git a/servant/test/Doctests.hs b/servant/test/Doctests.hs index eb3f688c..d70de8f3 100644 --- a/servant/test/Doctests.hs +++ b/servant/test/Doctests.hs @@ -9,21 +9,31 @@ import Test.DocTest main :: IO () main = do files <- find always (extension ==? ".hs") "src" - cabalMacrosFile <- getCabalMacrosFile - doctest $ [ "-isrc" - , "-optP-include" - , "-optP" ++ cabalMacrosFile - , "-XOverloadedStrings" - , "-XFlexibleInstances" - , "-XMultiParamTypeClasses" - ] ++ files + mCabalMacrosFile <- getCabalMacrosFile + doctest $ "-isrc" : + (maybe [] (\ f -> ["-optP-include", "-optP" ++ f]) mCabalMacrosFile) ++ + "-XOverloadedStrings" : + "-XFlexibleInstances" : + "-XMultiParamTypeClasses" : + files -getCabalMacrosFile :: IO FilePath +getCabalMacrosFile :: IO (Maybe 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 - xs -> error $ "ran doctests with multiple dist/dist-sandbox-xxxxx's: \n" - ++ show xs ++ "\nTry cabal clean" + 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 diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 00000000..7c62ac7a --- /dev/null +++ b/stack.yaml @@ -0,0 +1,15 @@ +flags: + servant-js: + example: false +packages: +- servant/ +- servant-blaze/ +- servant-client/ +- servant-docs/ +- servant-examples/ +- servant-js/ +- servant-lucid/ +- servant-mock/ +- servant-server/ +extra-deps: [] +resolver: nightly-2015-07-24