@@ -6,26 +6,57 @@
6# (2) Detect the platform and run tests applicable to the platform, (3)
6# (2) Detect the platform and run tests applicable to the platform, (3)
7# add a test for windows/msys
7# add a test for windows/msys
9+# TODO: tee the output to a log file
9−SCRIPT_DIR=$(cd `dirname $0`; pwd)
11+SCRIPT_DIR=$(cd "$(dirname "$0")" || exit; pwd)
12+SCRIPT_NAME=$(basename "$0")
10−source $SCRIPT_DIR/build-lib.sh
13+source "$SCRIPT_DIR/build-lib.sh"
12#------------------------------------------------------------------------------
15#------------------------------------------------------------------------------
13# Prime version (GHC 8.10)
16# Prime version (GHC 8.10)
14#------------------------------------------------------------------------------
17#------------------------------------------------------------------------------
16−GHC_PRIME=ghc8104
19+# XXX take these from command line
20+GHC_PRIME_NIX="ghc8104"
17GHC_PRIME_VER="8.10"
21GHC_PRIME_VER="8.10"
24+# Without cabal project file, it will not run any tests
19ghc_prime_dist () {
25ghc_prime_dist () {
20 nix-shell \
26 nix-shell \
21− --argstr compiler "$GHC_PRIME" \
27+ --argstr compiler "$GHC_PRIME_NIX" \
29+ packcheck.sh cabal-v2 \
30+ GHCVER=$GHC_PRIME_VER \
31+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
32+ CABAL_DISABLE_DEPS=y \
36+# With cabal.project file, it will run the tests
37+ghc_prime_dist_tests () {
39+ --argstr compiler "$GHC_PRIME_NIX" \
23 packcheck.sh cabal-v2 \
41 packcheck.sh cabal-v2 \
24 GHCVER=$GHC_PRIME_VER \
42 GHCVER=$GHC_PRIME_VER \
43+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
44+ CABAL_PROJECT=cabal.project \
25 CABAL_DISABLE_DEPS=y \
45 CABAL_DISABLE_DEPS=y \
26 CABAL_CHECK_RELAX=y"
46 CABAL_CHECK_RELAX=y"
49+# With stack.yaml file, it will run the tests
50+ghc_prime_dist_tests_stack () {
52+ --argstr compiler "$GHC_PRIME_NIX" \
55+ GHCVER=$GHC_PRIME_VER \
56+ STACK_BUILD_OPTIONS="--jobs $JOBS --system-ghc" \
57+ STACK_YAML=stack.yaml"
29# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
60# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
30# requires fusion-plugin.
61# requires fusion-plugin.
@@ -33,21 +64,22 @@ PERF_FLAGS="--flag inspection --flag fusion-plugin"
34ghc_prime_perf () {
65ghc_prime_perf () {
35 nix-shell \
66 nix-shell \
36− --argstr compiler "$GHC_PRIME" \
67+ --argstr compiler "$GHC_PRIME_NIX" \
37 --argstr c2nix "--flag inspection" \
68 --argstr c2nix "--flag inspection" \
39− bin/bench.sh --cabal-build-options \
40− \"--project-file cabal.project.Werror $PERF_FLAGS\" --quick --raw;\
41 bin/test.sh --cabal-build-options \
70 bin/test.sh --cabal-build-options \
71+ \"--jobs=$JOBS --project-file cabal.project.Werror $PERF_FLAGS\";\
72+ bin/bench.sh --cabal-build-options \
42− \"--project-file cabal.project.Werror $PERF_FLAGS\";"
73+ \"--jobs=$JOBS --project-file cabal.project.Werror $PERF_FLAGS\" \
45ghc_prime_O0 () {
77ghc_prime_O0 () {
46 nix-shell \
78 nix-shell \
47− --argstr compiler "$GHC_PRIME" \
79+ --argstr compiler "$GHC_PRIME_NIX" \
49 bin/test.sh --cabal-build-options \
81 bin/test.sh --cabal-build-options \
50− \"--project-file cabal.project.O0\""
82+ \"--jobs=$JOBS --project-file cabal.project.O0\""
53#------------------------------------------------------------------------------
85#------------------------------------------------------------------------------
@@ -62,22 +94,22 @@ lint () {
62 HLINT_TARGETS="src test benchmark"
94 HLINT_TARGETS="src test benchmark"
65−Werror () {
97+werror () {
66 nix-shell \
98 nix-shell \
67− --argstr compiler "$GHC_PRIME" \
99+ --argstr compiler "$GHC_PRIME_NIX" \
68 --run "cabal build --project-file cabal.project.Werror-nocode all"
100 --run "cabal build --project-file cabal.project.Werror-nocode all"
71−ghc_prime_werror () {
103+ghc_prime_Werror () {
72 nix-shell \
104 nix-shell \
73− --argstr compiler "$GHC_PRIME" \
105+ --argstr compiler "$GHC_PRIME_NIX" \
74− --run "cabal build --project-file cabal.project.Werror all"
106+ --run "cabal build --jobs=$JOBS --project-file cabal.project.Werror all"
77ghc_prime_doctests () {
109ghc_prime_doctests () {
78 nix-shell \
110 nix-shell \
79− --argstr compiler "$GHC_PRIME" \
111+ --argstr compiler "$GHC_PRIME_NIX" \
80− --run "cabal build --project-file cabal.project.doctest all"
112+ --run "cabal build --jobs=$JOBS --project-file cabal.project.doctest all"
81 cabal-docspec --timeout 60
113 cabal-docspec --timeout 60
@@ -90,36 +122,40 @@ ghc_prime_doctests () {
91ghc_prime_coverage () {
123ghc_prime_coverage () {
92 nix-shell \
124 nix-shell \
93− --argstr compiler "$GHC_PRIME" \
125+ --argstr compiler "$GHC_PRIME_NIX" \
94− --run "bin/test.sh --coverage"
126+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS\" --coverage"
97#------------------------------------------------------------------------------
129#------------------------------------------------------------------------------
99#------------------------------------------------------------------------------
131#------------------------------------------------------------------------------
101−ghc_prime_dev () {
133+ghc_prime_dev_perf () {
102 nix-shell \
134 nix-shell \
103− --argstr compiler "$GHC_PRIME" \
135+ --argstr compiler "$GHC_PRIME_NIX" \
104− --run "bin/test.sh --cabal-build-options \"--flag dev\""
137+ bin/test.sh --cabal-build-options \
138+ \"--jobs=$JOBS --flag dev\";\
139+ bin/bench.sh --cabal-build-options \
140+ \"--jobs=$JOBS --flag dev $PERF_FLAGS\" --quick --raw"
107ghc_prime_c_malloc () {
143ghc_prime_c_malloc () {
108 nix-shell \
144 nix-shell \
109− --argstr compiler "$GHC_PRIME" \
145+ --argstr compiler "$GHC_PRIME_NIX" \
110− --run "bin/test.sh --cabal-build-options \"--flag use-c-malloc\""
146+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag use-c-malloc\""
113ghc_prime_debug () {
149ghc_prime_debug () {
114 nix-shell \
150 nix-shell \
115− --argstr compiler "$GHC_PRIME" \
151+ --argstr compiler "$GHC_PRIME_NIX" \
116− --run "bin/test.sh --cabal-build-options \"--flag debug\""
152+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag debug\""
119ghc_prime_streamk () {
155ghc_prime_streamk () {
120 nix-shell \
156 nix-shell \
121− --argstr compiler "$GHC_PRIME" \
157+ --argstr compiler "$GHC_PRIME_NIX" \
122− --run "bin/test.sh --cabal-build-options \"--flag streamk\""
158+ --run "bin/test.sh --cabal-build-options \"--jobs=$JOBS --flag streamk\""
125#------------------------------------------------------------------------------
161#------------------------------------------------------------------------------
@@ -135,6 +171,7 @@ ghc () {
136 packcheck.sh cabal-v2 \
172 packcheck.sh cabal-v2 \
137 GHCVER=$2 \
173 GHCVER=$2 \
174+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
138 CABAL_DISABLE_DEPS=y \
175 CABAL_DISABLE_DEPS=y \
139 CABAL_CHECK_RELAX=y \
176 CABAL_CHECK_RELAX=y \
140 DISABLE_SDIST_BUILD=y \
177 DISABLE_SDIST_BUILD=y \
@@ -155,6 +192,7 @@ ghcHEAD () {
156 packcheck.sh cabal-v2 \
193 packcheck.sh cabal-v2 \
157 GHCVER=9.3 \
194 GHCVER=9.3 \
195+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
158 CABAL_CHECK_RELAX=y \
196 CABAL_CHECK_RELAX=y \
159 DISABLE_SDIST_BUILD=y \
197 DISABLE_SDIST_BUILD=y \
160 CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
198 CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
@@ -168,6 +206,7 @@ ghcjs () {
168 export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
206 export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
169 packcheck.sh cabal-v2 \
207 packcheck.sh cabal-v2 \
170 GHCVER=8.4.0 \
208 GHCVER=8.4.0 \
209+ CABAL_BUILD_OPTIONS="--jobs=$JOBS" \
171 CABAL_CHECK_RELAX=y \
210 CABAL_CHECK_RELAX=y \
172 DISABLE_SDIST_BUILD=y \
211 DISABLE_SDIST_BUILD=y \
173 DISABLE_TEST=y \
212 DISABLE_TEST=y \
@@ -179,54 +218,79 @@ ghcjs () {
179# Read command line
218# Read command line
180#-----------------------------------------------------------------------------
219#-----------------------------------------------------------------------------
182−ALL_TARGETS="\
221+RELEASE_CI_TARGETS="\
183ghc_prime_dist \
222ghc_prime_dist \
223+ghc_prime_dist_tests \
184ghc_prime_perf \
224ghc_prime_perf \
185ghc_prime_O0 \
225ghc_prime_O0 \
186ghc_prime_Werror \
226ghc_prime_Werror \
187ghc_prime_doctests \
227ghc_prime_doctests \
188ghc_prime_coverage \
228ghc_prime_coverage \
190ghc_prime_c_malloc \
229ghc_prime_c_malloc \
191ghc_prime_debug \
230ghc_prime_debug \
192ghc_prime_streamk \
231ghc_prime_streamk \
237+# XXX We should include dev as well but it has some test and benchmark
238+# failures to be fixed.
240+$RELEASE_CI_TARGETS \
241+ghc_prime_dist_tests_stack \
200print_targets () {
246print_targets () {
201 echo "Available targets: all $ALL_TARGETS"
247 echo "Available targets: all $ALL_TARGETS"
204print_help () {
250print_help () {
205− echo "Usage: $0 --targets <space separated target names>"
252+ echo "$SCRIPT_NAME --targets <space separated target names>"
253+ echo "$SCRIPT_NAME --release"
206 print_targets
254 print_targets
210while test -n "$1"
260while test -n "$1"
212 case $1 in
262 case $1 in
213 -h|--help|help) print_help ;;
264 -h|--help|help) print_help ;;
265+ --release) RELEASE_CI=1; shift; break ;;
214 # options with arguments
266 # options with arguments
215 --targets) shift; TARGETS=$1; shift ;;
267 --targets) shift; TARGETS=$1; shift ;;
216 --) shift; break ;;
268 --) shift; break ;;
217− -*|--*) echo "Unknown flags: $*"; echo; print_help ;;
269+ -*) echo "Unknown flags: $*"; echo; print_help ;;
218 *) break ;;
270 *) break ;;
222if test -z "$TARGETS"
274if test -z "$TARGETS"
276+ if test "$RELEASE_CI" -eq 1
278+ TARGETS="$RELEASE_CI_TARGETS"
280+ echo "No targets specified"
284+ if test "$RELEASE_CI" -eq 1
286+ echo "--targets and --release cannot be used together"
224− print_help
287+ print_help
227−for i in "$TARGETS"
291+for i in $TARGETS
229− if test "$(has_item "$ALL_TARGETS" $i)" != "$i"
293+ if test "$(has_item "$ALL_TARGETS" "$i")" != "$i"
231 echo "Unrecognized target: $i"
295 echo "Unrecognized target: $i"
232 print_help
296 print_help
@@ -244,7 +308,16 @@ then
244 TARGETS="$ALL_TARGETS"
308 TARGETS="$ALL_TARGETS"
314+ echo "--------------------------------------------------"
316+ echo "--------------------------------------------------"
247for i in $TARGETS
319for i in $TARGETS
249 $i || { echo "$i failed."; exit 1; }
322 $i || { echo "$i failed."; exit 1; }