2 # shellcheck disable=SC2086
5 #######################################################################
12 CABALINSTALLTESTS
=true
19 #######################################################################
23 ./validate.sh - build & test
25 Usage: ./validate.sh [ -j JOBS | -l | -C | -c | -s | -w HC | -x CABAL | -y CABALPLAN | -d | -v ]
26 A script which runs all the tests.
29 -j JOBS cabal v2-build -j argument (default: $JOBS)
30 -l Test Cabal-the-library only (default: $CABALONLY)
31 -C Don't run Cabal tests (default: $CABALTESTS)
32 -c Don't run cabal-install tests (default: $CABALINSTALLTESTS)
33 -s Don't run cabal-testsuite tests (default: $CABALSUITETESTS)
35 -x CABAL With cabal-install
36 -y CABALPLAN With cabal-plan
37 -d Build dependencies only
44 #######################################################################
52 RESET
='\033[0m' # No Color
54 JOB_START_TIME
=$
(date +%s
)
57 PRETTYCMD
=$
(echo "$@" |
sed -E 's/\/home[^ ]*\/([^\/])/**\/\1/g')
58 echo "$BLUE>>> $PRETTYCMD $RESET"
59 start_time
=$
(date +%s
)
66 # echo "MOCK" > "$OUTPUT"
70 duration
=$
((end_time
- start_time
))
71 tduration
=$
((end_time
- JOB_START_TIME
))
73 if [ $RET -eq 0 ]; then
75 # if output is relatively short, show everything
76 if [ "$(wc -l < "$OUTPUT")" -le 50 ]; then
86 echo "$GREEN<<< $PRETTYCMD $RESET ($duration/$tduration sec)"
95 echo "$RED<<< $PRETTYCMD $RESET ($duration/$tduration sec, $RET)"
96 echo "$RED<<< $* $RESET ($duration/$tduration sec, $RET)"
103 JOB_END_TIME
=$
(date +%s
)
104 tduration
=$
((JOB_END_TIME
- JOB_START_TIME
))
106 echo "$CYAN=== END ============================================ $(date +%T) === $RESET"
107 echo "$CYAN!!! Validation took $tduration seconds. $RESET"
111 #######################################################################
113 while getopts 'j:lCcsw:x:y:dv' flag
; do
121 c
) CABALINSTALLTESTS
=false
123 s
) CABALSUITETESTS
=false
129 y
) CABALPLAN
="$OPTARG"
140 shift $
((OPTIND
- 1))
143 #######################################################################
145 if [ "xhelp" = "x$1" ]; then
149 TESTSUITEJOBS
="-j$JOBS"
152 # assume compiler is GHC
153 RUNHASKELL
=$
(echo $HC |
sed -E 's/ghc(-[0-9.]*)$/runghc\1/')
155 echo "$CYAN=== validate.sh ======================================== $(date +%T) === $RESET"
159 runhaskell $RUNHASKELL
160 cabal-install: $CABAL
161 cabal-plan: $CABALPLAN
163 Cabal tests: $CABALTESTS
164 cabal-install tests: $CABALINSTALLTESTS
165 cabal-testsuite: $CABALSUITETESTS
166 library only: $CABALONLY
167 dependencies only: $DEPSONLY
173 timed
$CABAL --version
174 timed
$CABALPLAN --version
177 #######################################################################
179 # NOTE: This should match cabal-testsuite version
180 CABAL_VERSION
="3.0.0.0"
182 if [ "$(uname)" = "Linux" ]; then
189 PROJECTFILE
=cabal.project.validate.libonly
191 PROJECTFILE
=cabal.project.validate
194 BASEHC
=$
(basename $HC)
195 BUILDDIR
=dist-newstyle-validate-
$BASEHC
196 CABAL_TESTSUITE_BDIR
="$(pwd)/$BUILDDIR/build/$ARCH/$BASEHC/cabal-testsuite-${CABAL_VERSION}"
198 CABALNEWBUILD
="${CABAL} v2-build $JOBS -w $HC --builddir=$BUILDDIR --project-file=$PROJECTFILE"
199 CABALPLAN
="${CABALPLAN} --builddir=$BUILDDIR"
202 #######################################################################
204 if ! $CABALONLY; then
206 echo "$CYAN=== make cabal-install-dev ============================= $(date +%T) === $RESET"
208 # make cabal-install-dev
209 timed
${RUNHASKELL} cabal-dev-scripts
/src
/Preprocessor.hs
-o cabal-install
/cabal-install.cabal
-f CABAL_FLAG_LIB cabal-install
/cabal-install.cabal.pp
217 echo "$CYAN=== dependencies ====================================== $(date +%T) === $RESET"
219 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dep --dry-run ||
exit 1
220 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dep ||
exit 1
222 timed
$CABALNEWBUILD Cabal
--enable-tests --disable-benchmarks --dep --dry-run ||
exit 1
223 timed
$CABALNEWBUILD Cabal
--enable-tests --disable-benchmarks --dep ||
exit 1
226 # Unfortunately we can not install cabal-install or cabal-testsuite dependencies:
227 # that would build Cabal-lib!
235 #######################################################################
237 echo "$CYAN=== Cabal: build ======================================= $(date +%T) === $RESET"
239 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dry-run ||
exit 1
240 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks --dep ||
exit 1
241 timed
$CABALNEWBUILD Cabal
:lib
:Cabal
--enable-tests --disable-benchmarks ||
exit 1
244 echo "$CYAN=== Cabal: test ======================================== $(date +%T) === $RESET"
246 timed
$CABALNEWBUILD Cabal
:tests
--enable-tests --disable-benchmarks --dry-run ||
exit 1
247 timed
$CABALNEWBUILD Cabal
:tests
--enable-tests --disable-benchmarks --dep ||
exit 1
248 timed
$CABALNEWBUILD Cabal
:tests
--enable-tests --disable-benchmarks ||
exit 1
250 CMD
="$($CABALPLAN list-bin Cabal:test:unit-tests) $TESTSUITEJOBS --hide-successes --with-ghc=$HC"
251 (cd Cabal
&& timed
$CMD) ||
exit 1
253 CMD
="$($CABALPLAN list-bin Cabal:test:check-tests) $TESTSUITEJOBS --hide-successes"
254 (cd Cabal
&& timed
$CMD) ||
exit 1
256 CMD
="$($CABALPLAN list-bin Cabal:test:parser-tests) $TESTSUITEJOBS --hide-successes"
257 (cd Cabal
&& timed
$CMD) ||
exit 1
259 CMD
=$
($CABALPLAN list-bin Cabal
:test:hackage-tests
)
260 (cd Cabal
&& timed
$CMD read-fields
) ||
exit 1
261 (cd Cabal
&& timed
$CMD parsec d
) ||
exit 1
262 (cd Cabal
&& timed
$CMD roundtrip k
) ||
exit 1
266 if $CABALSUITETESTS; then
268 echo "$CYAN=== cabal-testsuite: build ============================= $(date +%T) === $RESET"
270 timed
$CABALNEWBUILD cabal-testsuite
--enable-tests --disable-benchmarks --dry-run ||
exit 1
271 timed
$CABALNEWBUILD cabal-testsuite
--enable-tests --disable-benchmarks --dep ||
exit 1
272 timed
$CABALNEWBUILD cabal-testsuite
--enable-tests --disable-benchmarks ||
exit 1
274 echo "$CYAN=== cabal-testsuite: Cabal test ======================== $(date +%T) === $RESET"
276 CMD
="$($CABALPLAN list-bin cabal-testsuite:exe:cabal-tests) --builddir=$CABAL_TESTSUITE_BDIR $TESTSUITEJOBS --with-ghc=$HC --hide-successes"
277 (cd cabal-testsuite
&& timed
$CMD) ||
exit 1
279 fi # CABALSUITETESTS (Cabal)
281 # If testing only library, stop here
288 #######################################################################
290 echo "$CYAN=== cabal-install: build =============================== $(date +%T) === $RESET"
292 timed
$CABALNEWBUILD cabal-install
--enable-tests --disable-benchmarks --dry-run ||
exit 1
294 # For some reason this sometimes fails. So we try twice.
295 CMD
="$CABALNEWBUILD cabal-install --enable-tests --disable-benchmarks"
296 (timed
$CMD) ||
(timed
$CMD) ||
exit 1
299 if $CABALINSTALLTESTS; then
300 echo "$CYAN=== cabal-install: test ================================ $(date +%T) === $RESET"
302 # this are sorted in asc time used, quicker tests first.
303 CMD
="$($CABALPLAN list-bin cabal-install:test:solver-quickcheck) $TESTSUITEJOBS --hide-successes"
304 (cd cabal-install
&& timed
$CMD) ||
exit 1
306 # This doesn't work in parallel either
307 CMD
="$($CABALPLAN list-bin cabal-install:test:unit-tests) -j1 --hide-successes"
308 (cd cabal-install
&& timed
$CMD) ||
exit 1
310 # Only single job, otherwise we fail with "Heap exhausted"
311 CMD
="$($CABALPLAN list-bin cabal-install:test:memory-usage-tests) -j1 --hide-successes"
312 (cd cabal-install
&& timed
$CMD) ||
exit 1
314 # This test-suite doesn't like concurrency
315 CMD
="$($CABALPLAN list-bin cabal-install:test:integration-tests2) -j1 --hide-successes --with-ghc=$HC"
316 (cd cabal-install
&& timed
$CMD) ||
exit 1
318 fi # CABALINSTALLTESTS
321 if $CABALSUITETESTS; then
322 echo "$CYAN=== cabal-testsuite: cabal-install test ================ $(date +%T) === $RESET"
324 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"
325 (cd cabal-testsuite
&& timed
$CMD) ||
exit 1
330 #######################################################################
334 #######################################################################