1
1
mirror of https://github.com/nmattia/snack.git synced 2024-11-28 12:27:41 +03:00
snack/script/test
Nicolas Mattia 85d44e5f7b Clean up
2018-07-03 15:55:56 +02:00

103 lines
1.4 KiB
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash
#!nix-shell -I nixpkgs=./nix
#!nix-shell -p git
#!nix-shell -p jq
#!nix-shell -p nix
#!nix-shell -p shfmt
#!nix-shell -p snack-exe
#!nix-shell -p glibcLocales
#!nix-shell --pure
# vim: ft=sh sw=2 et
set -euo pipefail
export LC_ALL="en_US.utf-8"
export LANG="en_US.utf-8"
## Functions
banner() {
echo
echo "--- $*"
}
capture_io() {
OUT_FILE="$1"
cat <<END_HEREDOC
import GHC.IO.Handle
import System.IO
old_stdout <- hDuplicate stdout
:{
withFile "$OUT_FILE" WriteMode $ \\h -> do
hDuplicateTo h stdout
$2
hDuplicateTo old_stdout stdout
:}
END_HEREDOC
}
export -f capture_io
fail() {
echo "ERROR: $*"
exit 1
}
## Main
cd "$(dirname "$0")/.."
banner "Test packages"
pushd tests/packages
./test
popd
banner "Test Template Haskell"
pushd tests/template-haskell
./test
popd
banner "Test Template Haskell 2"
pushd tests/template-haskell-2
./test
popd
banner "Test Template Haskell 3"
pushd tests/template-haskell-3
./test
popd
banner "Test Template Haskell 4"
pushd tests/template-haskell-4
./test
popd
banner "Test library"
pushd tests/library
./test
popd
banner "Test library-2"
pushd tests/library-2
./test
popd
banner "Test extensions"
pushd tests/extensions
./test
popd
banner "HPack"
pushd tests/hpack
./test
popd
banner "Test this file's formatting"
list=$(shfmt -i 2 -l script/test)
if [[ -n "$list" ]]; then
fail "Please apply script/snack-fmt to format script/test"
fi
echo OK