-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-all.sh
executable file
·94 lines (83 loc) · 2.08 KB
/
test-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace
if [ "$#" -ne "1" ] ; then
echo "Usage: test-all.sh COMMAND" 1>&2
echo 1>&2
echo "Commands:" 1>&2
echo " cabal test all GHC versions using Cabal" 1>&2
echo " github output GitHub actions matrix configuration" 1>&2
echo " stack test all GHC versions using Stack" 1>&2
exit 2
fi
ghcvers() {
awk '/^tested-with:$/{p=1;next}/^$/{p=0}p' ./*.cabal | sed 's/^[^=]*==//'
}
ghcvers_lower() {
grep ^with-compiler: cabal-bounds-lower.project | sed 's/.*-//'
}
ghcvers_upper() {
grep ^with-compiler: cabal-bounds-upper.project | sed 's/.*-//'
}
mockhr="$(command -v hr >/dev/null 2>&1 && echo "0" || echo "1")"
hr() {
echo "--{ $* }--------------------------------------"
}
test "${mockhr}" -eq "1" || unset -f hr
fail() {
echo
echo "Fail!"
exit 1
}
cabaltest() {
local ghcver="$1"
local projfile="cabal-${ghcver}.project"
hr "${ghcver}"
declare -a args
args+=("--with-ghc=ghc-${ghcver}")
if [ -e "${projfile}" ] ; then
args+=("--project-file=${projfile}")
fi
args+=("--enable-tests")
args+=("--enable-benchmarks")
cabal v2-build "${args[@]}" || fail
cabal v2-test "${args[@]}" --test-show-details=always || fail
cabal v2-haddock "${args[@]}" || fail
}
stacktest() {
local ghcver="$1"
local config="stack-${ghcver}.yaml"
hr "${ghcver}"
declare -a args
args+=("--stack-yaml=${config}")
stack build "${args[@]}" --test --bench --no-run-tests --no-run-benchmarks \
|| fail
stack test "${args[@]}" || fail
stack haddock "${args[@]}" || fail
}
case "$1" in
"cabal" )
while IFS=$'\n' read -r ghcver ; do
cabaltest "${ghcver}"
done < <(ghcvers)
;;
"github" )
echo "ghcvers=$(ghcvers | jq -Rnc '[inputs]')"
echo "ghcvers_lower=$(ghcvers_lower | jq -Rnc '[inputs]')"
echo "ghcvers_upper=$(ghcvers_upper | jq -Rnc '[inputs]')"
exit 0
;;
"stack" )
while IFS=$'\n' read -r ghcver ; do
stacktest "${ghcver}"
done < <(ghcvers)
;;
* )
echo "error: unknown command: $1" 1>&2
exit 2
;;
esac
echo
echo "Success!"