2 # shellcheck disable=SC2086
5 if [ "$1" = "help" ]; then
7 This is a helper script to build and run tests locally.
8 It does about the same things as appveyor.yml, only using cabal new-build.
12 $ HC=ghc-7.10.3 sh validate.sh
14 Multiple ghcs (serial), this takes very long.
16 $ sh validate.sh ghc-7.6.3 ghc-7.8.4 ghc-7.10.3 ghc-8.0.2 ghc-8.2.2
18 Params (with defaults)
20 JOBS=-j4 cabal new-build -j argument
21 TESTSUITEJOBS=-j3 cabal-tests -j argument
22 CABALTESTS=true Run Cabal tests
23 CABALINSTALLTESTS=true Run cabal-install tests
24 CABALSUITETESTS=true Run cabal-testsuite
29 # Loop thru compilers if given as an argument
41 TESTSUITEJOBS
=${TESTSUITEJOBS--j3}
43 CABALTESTS
=${CABALTESTS-true}
44 CABALINSTALLTESTS
=${CABALINSTALLTESTS-true}
45 CABALSUITETESTS
=${CABALSUITETESTS-true}
47 CABAL_VERSION
="2.3.0.0"
48 if [ "$(uname)" = "Linux" ]; then
54 BUILDDIR
=dist-newstyle-validate-
$HC
55 CABAL_TESTSUITE_BDIR
="$(pwd)/$BUILDDIR/build/$ARCH/$HC/cabal-testsuite-${CABAL_VERSION}"
57 CABALNEWBUILD
="cabal new-build $JOBS -w $HC --builddir=$BUILDDIR --project-file=cabal.project.validate"
58 CABALPLAN
="cabal-plan --builddir=$BUILDDIR"
66 RESET
='\033[0m' # No Color
68 JOB_START_TIME
=$
(date +%s
)
71 PRETTYCMD
=$
(echo "$@" |
sed -E 's/\/home[^ ]*\/([^\/])/**\/\1/g')
72 echo "$BLUE>>> $PRETTYCMD $RESET"
73 start_time
=$
(date +%s
)
76 # echo "MOCK" > "$OUTPUT"
80 duration
=$
((end_time
- start_time
))
81 tduration
=$
((end_time
- JOB_START_TIME
))
83 if [ $RET -eq 0 ]; then
84 echo "$GREEN<<< $PRETTYCMD $RESET ($duration/$tduration sec)"
86 # if output is relatively short, show everything
87 if [ "$(wc -l < "$OUTPUT")" -le 20 ]; then
99 echo "$RED<<< $PRETTYCMD $RESET ($duration/$tduration sec, $RET)"
101 echo "$RED<<< $* $RESET ($duration/$tduration sec, $RET)"
108 echo "$CYAN!!! Validating with $HC $RESET"
111 timed cabal
--version
112 timed cabal-plan
--version
116 echo "$CYAN=== Cabal: build ======================================= $(date +%T) === $RESET"
118 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dry-run ||
exit 1
119 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dep ||
exit 1
120 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks ||
exit 1
122 # Environment files interfere with legacy Custom setup builds in sandbox
123 # https://github.com/haskell/cabal/issues/4642
124 rm -rf .ghc.environment.
*
128 echo "$CYAN=== Cabal: test ======================================== $(date +%T) === $RESET"
130 timed
$CABALNEWBUILD Cabal
:tests
--enable-tests --disable-benchmarks --dry-run ||
exit 1
131 timed
$CABALNEWBUILD Cabal
:tests
--enable-tests --disable-benchmarks ||
exit 1
132 rm -rf .ghc.environment.
*
134 CMD
="$($CABALPLAN list-bin Cabal:test:unit-tests) $TESTSUITEJOBS --hide-successes"
135 (cd Cabal
&& timed
$CMD) ||
exit 1
137 CMD
="$($CABALPLAN list-bin Cabal:test:check-tests) $TESTSUITEJOBS --hide-successes"
138 (cd Cabal
&& timed
$CMD) ||
exit 1
140 CMD
="$($CABALPLAN list-bin Cabal:test:parser-tests) $TESTSUITEJOBS --hide-successes"
141 (cd Cabal
&& timed
$CMD) ||
exit 1
143 CMD
=$
($CABALPLAN list-bin Cabal
:test:hackage-tests
)
144 (cd Cabal
&& timed
$CMD parsec d
) ||
exit 1
145 (cd Cabal
&& timed
$CMD roundtrip k
) ||
exit 1
151 # cabal test ssuite is run first
152 echo "$CYAN=== cabal-install cabal-testsuite: build =============== $(date +%T) === $RESET"
154 timed
$CABALNEWBUILD all
--enable-tests --disable-benchmarks --dry-run ||
exit 1
156 # For some reason this sometimes fails. So we try twice.
157 CMD
="$CABALNEWBUILD all --enable-tests --disable-benchmarks"
158 (timed
$CMD) ||
(timed
$CMD) ||
exit 1
159 rm -rf .ghc.environment.
*
162 # cabal-install tests
163 if $CABALINSTALLTESTS; then
164 echo "$CYAN=== cabal-install: test ================================ $(date +%T) === $RESET"
166 # this are sorted in asc time used, quicker tests first.
167 CMD
="$($CABALPLAN list-bin cabal-install:test:solver-quickcheck) $TESTSUITEJOBS --hide-successes"
168 (cd cabal-install
&& timed
$CMD) ||
exit 1
170 # This doesn't work in parallel either
171 CMD
="$($CABALPLAN list-bin cabal-install:test:unit-tests) -j1 --hide-successes"
172 (cd cabal-install
&& timed
$CMD) ||
exit 1
174 # Only single job, otherwise we fail with "Heap exhausted"
175 CMD
="$($CABALPLAN list-bin cabal-install:test:memory-usage-tests) -j1 --hide-successes"
176 (cd cabal-install
&& timed
$CMD) ||
exit 1
178 # This test-suite doesn't like concurrency
179 CMD
="$($CABALPLAN list-bin cabal-install:test:integration-tests2) -j1 --hide-successes"
180 (cd cabal-install
&& timed
$CMD) ||
exit 1
182 fi # CABALINSTALLTESTS
185 # cabal-testsuite tests
186 if $CABALSUITETESTS; then
187 echo "$CYAN=== cabal-testsuite: test ============================== $(date +%T) === $RESET"
189 CMD
="$($CABALPLAN list-bin cabal-testsuite:exe:cabal-tests) --builddir=$CABAL_TESTSUITE_BDIR --with-cabal=$($CABALPLAN list-bin cabal-install:exe:cabal) $TESTSUITEJOBS --hide-successes"
190 (cd cabal-testsuite
&& timed
$CMD) ||
exit 1
196 JOB_END_TIME
=$
(date +%s
)
197 tduration
=$
((JOB_END_TIME
- JOB_START_TIME
))
199 echo "$CYAN!!! Validation took $tduration seconds. $RESET"