Merge pull request #78 from haskell-servant/wip-fix-test-all-script

scripts: install all of the servant ecosystem at once, for consistent dependencies
This commit is contained in:
Christian Marie 2015-05-15 15:49:03 +10:00
commit 13a8813422
5 changed files with 32 additions and 6 deletions

View File

@ -26,19 +26,19 @@ readarray -t SOURCES < "$SOURCES_TXT"
prepare_sandbox () { prepare_sandbox () {
$CABAL sandbox init $CABAL sandbox init
for s in ${SOURCES[@]} ; do for s in ${SOURCES[@]} ; do
(cd "$s" && $CABAL sandbox init --sandbox=../ && $CABAL sandbox add-source .) (cd "$s" && $CABAL sandbox init --sandbox=../.cabal-sandbox/ && $CABAL sandbox add-source .)
done done
$CABAL install --enable-tests ${SOURCES[@]}
} }
test_each () { test_each () {
for s in ${SOURCES[@]} ; do for s in ${SOURCES[@]} ; do
echo "Testing $s..." echo "Testing $s..."
cd "$s" pushd "$s"
$CABAL install --only-dependencies --enable-tests
$CABAL configure --enable-tests --ghc-options="$GHC_FLAGS" $CABAL configure --enable-tests --ghc-options="$GHC_FLAGS"
$CABAL build $CABAL build
$CABAL test $CABAL test
cd .. popd
done done
} }

View File

@ -113,6 +113,8 @@ test-suite doctests
, servant , servant
, doctest , doctest
, filemanip , filemanip
, directory
, filepath
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: test/Doctests.hs main-is: test/Doctests.hs
buildable: True buildable: True

View File

@ -1,14 +1,18 @@
module Main where module Main where
import Data.List (isPrefixOf)
import System.Directory
import System.FilePath
import System.FilePath.Find import System.FilePath.Find
import Test.DocTest import Test.DocTest
main :: IO () main :: IO ()
main = do main = do
files <- find always (extension ==? ".hs") "src" files <- find always (extension ==? ".hs") "src"
cabalMacrosFile <- getCabalMacrosFile
doctest $ [ "-isrc" doctest $ [ "-isrc"
, "-optP-include" , "-optP-include"
, "-optPdist/build/autogen/cabal_macros.h" , "-optP" ++ cabalMacrosFile
, "-XOverloadedStrings" , "-XOverloadedStrings"
, "-XFlexibleInstances" , "-XFlexibleInstances"
, "-XMultiParamTypeClasses" , "-XMultiParamTypeClasses"
@ -16,3 +20,10 @@ main = do
, "-XTypeOperators" , "-XTypeOperators"
] ++ files ] ++ files
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

View File

@ -107,6 +107,8 @@ test-suite doctests
, servant , servant
, doctest , doctest
, filemanip , filemanip
, directory
, filepath
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
main-is: test/Doctests.hs main-is: test/Doctests.hs
buildable: True buildable: True

View File

@ -1,16 +1,27 @@
module Main where module Main where
import Data.List (isPrefixOf)
import System.Directory
import System.FilePath
import System.FilePath.Find import System.FilePath.Find
import Test.DocTest import Test.DocTest
main :: IO () main :: IO ()
main = do main = do
files <- find always (extension ==? ".hs") "src" files <- find always (extension ==? ".hs") "src"
cabalMacrosFile <- getCabalMacrosFile
doctest $ [ "-isrc" doctest $ [ "-isrc"
, "-optP-include" , "-optP-include"
, "-optPdist/build/autogen/cabal_macros.h" , "-optP" ++ cabalMacrosFile
, "-XOverloadedStrings" , "-XOverloadedStrings"
, "-XFlexibleInstances" , "-XFlexibleInstances"
, "-XMultiParamTypeClasses" , "-XMultiParamTypeClasses"
] ++ files ] ++ files
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