A little documention
[cabal.git] / travis-script.sh
blob9e07d6e425eedc429024d90fb451893a5aa37d39
1 #!/bin/sh
3 # ATTENTION! Before editing this file, maybe you can make a
4 # separate script to do your test? We don't want individual
5 # Travis builds to take too long (they time out at 50min and
6 # it's generally unpleasant if the build takes that long.)
7 # If you make a separate matrix entry in .travis.yml it can
8 # be run in parallel.
10 # NB: the '|| exit $?' workaround is required on old broken versions of bash
11 # that ship with OS X. See https://github.com/haskell/cabal/pull/3624 and
12 # http://stackoverflow.com/questions/14970663/why-doesnt-bash-flag-e-exit-when-a-subshell-fails
14 . ./travis-common.sh
16 # --hide-successes uses terminal control characters which mess up
17 # Travis's log viewer. So just print them all!
18 TEST_OPTIONS=""
20 # ---------------------------------------------------------------------
21 # Parse options
22 # ---------------------------------------------------------------------
24 usage() {
25 echo -e -n "Usage: `basename $0`\n-j jobs\n"
28 jobs="-j1"
29 while getopts ":hj:" opt; do
30 case $opt in
32 usage
33 exit 0
36 jobs="-j$OPTARG"
39 # Argument-less -j
40 if [ "$OPTARG" = "j" ]; then
41 jobs="-j"
44 \?)
45 echo "Invalid option: $OPTARG"
46 usage
47 exit 1
49 esac
50 done
51 shift $((OPTIND-1))
53 # Do not try to use -j with GHC older than 7.8
54 case $GHCVER in
55 7.4*|7.6*)
56 jobs=""
60 esac
62 # ---------------------------------------------------------------------
63 # Update the Cabal index
64 # ---------------------------------------------------------------------
66 timed cabal update
68 # ---------------------------------------------------------------------
69 # Install executables if necessary
70 # ---------------------------------------------------------------------
72 if ! command -v happy; then
73 timed cabal install $jobs happy
76 # ---------------------------------------------------------------------
77 # Setup our local project
78 # ---------------------------------------------------------------------
80 cp cabal.project.travis cabal.project.local
82 # hackage-repo-tool is a bit touchy to install on GHC 8.0, so instead we
83 # do it via new-build. See also cabal.project.travis. The downside of
84 # doing it this way is that the build product cannot be cached, but
85 # hackage-repo-tool is a relatively small package so it's good.
86 timed cabal unpack hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}
88 # ---------------------------------------------------------------------
89 # Cabal
90 # ---------------------------------------------------------------------
92 # Needed to work around some bugs in nix-local-build code.
93 export CABAL_BUILDDIR="${CABAL_BDIR}"
95 if [ "x$CABAL_INSTALL_ONLY" != "xYES" ] ; then
96 # We're doing a full build and test of Cabal
98 # NB: Best to do everything for a single package together as it's
99 # more efficient (since new-build will uselessly try to rebuild
100 # Cabal otherwise).
101 if [ "x$PARSEC" = "xYES" ]; then
102 timed cabal new-build $jobs -fparsec Cabal Cabal:unit-tests Cabal:parser-tests Cabal:parser-hackage-tests
103 else
104 timed cabal new-build $jobs Cabal Cabal:unit-tests
107 # Run haddock
108 (cd Cabal && timed cabal act-as-setup --build-type=Simple -- haddock --builddir=${CABAL_BDIR}) || exit $?
110 # Check for package warnings
111 (cd Cabal && timed cabal check) || exit $?
114 unset CABAL_BUILDDIR
116 # Build and run the package tests
118 export CABAL_BUILDDIR="${CABAL_TESTSUITE_BDIR}"
120 # NB: We always build this test runner, because it is used
121 # both by Cabal and cabal-install
122 timed cabal new-build $jobs cabal-testsuite:cabal-tests
124 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} -j3 $TEST_OPTIONS) || exit $?
126 # Redo the package tests with different versions of GHC
127 if [ "x$TEST_OTHER_VERSIONS" = "xYES" ]; then
128 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} $TEST_OPTIONS --with-ghc="/opt/ghc/7.0.4/bin/ghc")
129 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} $TEST_OPTIONS --with-ghc="/opt/ghc/7.2.2/bin/ghc")
130 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} $TEST_OPTIONS --with-ghc="/opt/ghc/head/bin/ghc")
133 unset CABAL_BUILDDIR
135 if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then
136 # If this fails, we WANT to fail, because the tests will not be running then
137 (timed ./travis/upload.sh) || exit $?
138 exit 0;
141 # ---------------------------------------------------------------------
142 # cabal-install
143 # ---------------------------------------------------------------------
145 # Needed to work around some bugs in nix-local-build code.
146 export CABAL_BUILDDIR="${CABAL_INSTALL_BDIR}"
148 if [ "x$DEBUG_EXPENSIVE_ASSERTIONS" = "xYES" ]; then
149 CABAL_INSTALL_FLAGS=-fdebug-expensive-assertions
152 # NB: For Travis, we do a *monolithic* build, which means all the
153 # test suites are baked into the cabal binary
154 timed cabal new-build $jobs $CABAL_INSTALL_FLAGS cabal-install:cabal
156 timed cabal new-build $jobs hackage-repo-tool
158 # Haddock
159 # TODO: Figure out why this needs to be run before big tests
160 (cd cabal-install && timed ${CABAL_INSTALL_SETUP} haddock --builddir=${CABAL_INSTALL_BDIR} ) || exit $?
162 # Tests need this
163 timed ${CABAL_INSTALL_BDIR}/build/cabal/cabal update
165 # Big tests
166 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} -j3 --skip-setup-tests --with-cabal ${CABAL_INSTALL_BDIR}/build/cabal/cabal --with-hackage-repo-tool ${HACKAGE_REPO_TOOL_BDIR}/build/hackage-repo-tool/hackage-repo-tool $TEST_OPTIONS) || exit $?
168 (cd cabal-install && timed cabal check) || exit $?
170 unset CABAL_BUILDDIR
172 # Check what we got
173 ${CABAL_INSTALL_BDIR}/build/cabal/cabal --version
175 # If this fails, we WANT to fail, because the tests will not be running then
176 (timed ./travis/upload.sh) || exit $?