servant/scripts/test-all.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

2015-04-20 11:57:55 +02:00
#!/bin/bash -
#===============================================================================
#
# FILE: test-all.sh
#
# USAGE: ./test-all.sh
#
# DESCRIPTION: Run tests for all source directories listed in $SOURCES.
# Uses local versions of those sources.
#
2015-04-20 19:13:06 +02:00
# REQUIREMENTS: bash >= 4
2015-04-20 11:57:55 +02:00
#===============================================================================
set -o nounset
set -o errexit
2015-04-20 19:13:06 +02:00
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
2015-04-20 11:57:55 +02:00
GHC_FLAGS="-Werror"
2015-04-20 19:13:06 +02:00
SOURCES_TXT="$( dirname $DIR)/sources.txt"
2015-04-20 19:52:29 +02:00
CABAL=${CABAL:-cabal}
2015-04-20 19:13:06 +02:00
declare -a SOURCES
readarray -t SOURCES < "$SOURCES_TXT"
2015-04-20 11:57:55 +02:00
prepare_sandbox () {
2015-04-20 19:52:29 +02:00
$CABAL sandbox init
2015-04-20 11:57:55 +02:00
for s in ${SOURCES[@]} ; do
2015-04-20 19:52:29 +02:00
(cd "$s" && $CABAL sandbox init --sandbox=../ && $CABAL sandbox add-source .)
2015-04-20 11:57:55 +02:00
done
}
test_each () {
for s in ${SOURCES[@]} ; do
echo "Testing $s..."
cd "$s"
2015-04-20 19:52:29 +02:00
$CABAL install --only-dependencies --enable-tests
$CABAL configure --enable-tests --ghc-options="$GHC_FLAGS"
$CABAL build
$CABAL test
2015-04-20 11:57:55 +02:00
cd ..
done
}
prepare_sandbox
test_each