Merge branch 'wip-fix-test-all-script' into wip-whitespace-comment

This commit is contained in:
Christian Marie 2015-05-15 10:36:16 +10:00
commit 1e9a5eedb9
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