git.iko.soy/typeable/servant
on master help sign in
Merge pull request #79 from haskell-servant/shahn/wip-fix-test-all-script

fix doctests for cabal-install-1.18

commitb5e558f78375063fd5244811910b06ba93eadcb5 authorChristian Marie <christian@ponies.io> dateThu 14 May 2015, 23:16 (11 years ago) parent07f8b6a0d47f45
4 files changed+28−2
servant-server/servant-server.cabal+2 servant-server/test/Doctests.hs+12−1 servant/servant.cabal+2 servant/test/Doctests.hs+12−1
servant-server/servant-server.cabal+2
@@ -113,6 +113,8 @@ test-suite doctests
113113 , servant
114114 , doctest
115115 , filemanip
116+ , directory
117+ , filepath
116118 type: exitcode-stdio-1.0
117119 main-is: test/Doctests.hs
118120 buildable: True
servant-server/test/Doctests.hs+12−1
@@ -1,14 +1,18 @@
11module Main where
22
3+import Data.List (isPrefixOf)
4+import System.Directory
5+import System.FilePath
36import System.FilePath.Find
47import Test.DocTest
58
69main :: IO ()
710main = do
811 files <- find always (extension ==? ".hs") "src"
12+ cabalMacrosFile <- getCabalMacrosFile
913 doctest $ [ "-isrc"
1014 , "-optP-include"
11− , "-optPdist/build/autogen/cabal_macros.h"
15+ , "-optP" ++ cabalMacrosFile
1216 , "-XOverloadedStrings"
1317 , "-XFlexibleInstances"
1418 , "-XMultiParamTypeClasses"
@@ -16,3 +20,10 @@ main = do
1620 , "-XTypeOperators"
1721 ] ++ files
1822
23+getCabalMacrosFile :: IO FilePath
24+getCabalMacrosFile = do
25+ contents <- getDirectoryContents "dist"
26+ let rest = "build" </> "autogen" </> "cabal_macros.h"
27+ return $ case filter ("dist-sandbox-" `isPrefixOf`) contents of
28+ [x] -> "dist" </> x </> rest
29+ [] -> "dist" </> rest
servant/servant.cabal+2
@@ -107,6 +107,8 @@ test-suite doctests
107107 , servant
108108 , doctest
109109 , filemanip
110+ , directory
111+ , filepath
110112 type: exitcode-stdio-1.0
111113 main-is: test/Doctests.hs
112114 buildable: True
servant/test/Doctests.hs+12−1
@@ -1,16 +1,27 @@
11module Main where
22
3+import Data.List (isPrefixOf)
4+import System.Directory
5+import System.FilePath
36import System.FilePath.Find
47import Test.DocTest
58
69main :: IO ()
710main = do
811 files <- find always (extension ==? ".hs") "src"
12+ cabalMacrosFile <- getCabalMacrosFile
913 doctest $ [ "-isrc"
1014 , "-optP-include"
11− , "-optPdist/build/autogen/cabal_macros.h"
15+ , "-optP" ++ cabalMacrosFile
1216 , "-XOverloadedStrings"
1317 , "-XFlexibleInstances"
1418 , "-XMultiParamTypeClasses"
1519 ] ++ files
1620
21+getCabalMacrosFile :: IO FilePath
22+getCabalMacrosFile = do
23+ contents <- getDirectoryContents "dist"
24+ let rest = "build" </> "autogen" </> "cabal_macros.h"
25+ return $ case filter ("dist-sandbox-" `isPrefixOf`) contents of
26+ [x] -> "dist" </> x </> rest
27+ [] -> "dist" </> rest