bootstrap.sh: Bump HTTP version.
[cabal.git] / travis-script.sh
blob66783cc42f3ecd8565f416b47124c9cfe29c6dae
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 # To be enabled temporarily when you need to pre-populate the Travis
21 # cache to avoid timeout.
22 #SKIP_TESTS=YES
24 # ---------------------------------------------------------------------
25 # Parse options
26 # ---------------------------------------------------------------------
28 usage() {
29 echo -e -n "Usage: `basename $0`\n-j jobs\n"
32 jobs="-j1"
33 while getopts ":hj:" opt; do
34 case $opt in
36 usage
37 exit 0
40 jobs="-j$OPTARG"
43 # Argument-less -j
44 if [ "$OPTARG" = "j" ]; then
45 jobs="-j"
48 \?)
49 echo "Invalid option: $OPTARG"
50 usage
51 exit 1
53 esac
54 done
55 shift $((OPTIND-1))
57 # Do not try to use -j with GHC older than 7.8
58 case $GHCVER in
59 7.4*|7.6*)
60 jobs=""
64 esac
66 # ---------------------------------------------------------------------
67 # Update the Cabal index
68 # ---------------------------------------------------------------------
70 timed cabal update
72 # ---------------------------------------------------------------------
73 # Install executables if necessary
74 # ---------------------------------------------------------------------
76 #if ! command -v happy; then
77 timed cabal install $jobs happy
78 #fi
80 # ---------------------------------------------------------------------
81 # Setup our local project
82 # ---------------------------------------------------------------------
84 cp cabal.project.travis cabal.project.local
86 # hackage-repo-tool is a bit touchy to install on GHC 8.0, so instead we
87 # do it via new-build. See also cabal.project.travis. The downside of
88 # doing it this way is that the build product cannot be cached, but
89 # hackage-repo-tool is a relatively small package so it's good.
90 timed cabal unpack hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}
92 # ---------------------------------------------------------------------
93 # Cabal
94 # ---------------------------------------------------------------------
96 # Needed to work around some bugs in nix-local-build code.
97 export CABAL_BUILDDIR="${CABAL_BDIR}"
99 if [ "x$CABAL_INSTALL_ONLY" != "xYES" ] ; then
100 # We're doing a full build and test of Cabal
102 # NB: Best to do everything for a single package together as it's
103 # more efficient (since new-build will uselessly try to rebuild
104 # Cabal otherwise).
105 timed cabal new-build $jobs Cabal Cabal:unit-tests Cabal:check-tests Cabal:parser-tests Cabal:hackage-tests --enable-tests
107 # Run haddock.
108 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
109 (cd Cabal && timed cabal act-as-setup --build-type=Simple -- haddock --builddir=${CABAL_BDIR}) || exit $?
112 # Check for package warnings
113 (cd Cabal && timed cabal check) || exit $?
116 unset CABAL_BUILDDIR
118 # Build and run the package tests
120 export CABAL_BUILDDIR="${CABAL_TESTSUITE_BDIR}"
122 # NB: We always build this test runner, because it is used
123 # both by Cabal and cabal-install
124 timed cabal new-build $jobs cabal-testsuite:cabal-tests
126 if [ "x$SKIP_TESTS" != "xYES" ]; then
127 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} -j3 $TEST_OPTIONS) || exit $?
130 # Redo the package tests with different versions of GHC
131 if [ "x$TEST_OTHER_VERSIONS" = "xYES" ]; then
132 (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")
133 (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")
134 (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")
137 unset CABAL_BUILDDIR
139 if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then
140 # If this fails, we WANT to fail, because the tests will not be running then
141 (timed ./travis/upload.sh) || exit $?
142 exit 0;
145 # ---------------------------------------------------------------------
146 # cabal-install
147 # ---------------------------------------------------------------------
149 # Needed to work around some bugs in nix-local-build code.
150 export CABAL_BUILDDIR="${CABAL_INSTALL_BDIR}"
152 if [ "x$DEBUG_EXPENSIVE_ASSERTIONS" = "xYES" ]; then
153 CABAL_INSTALL_FLAGS=-fdebug-expensive-assertions
156 # NB: For Travis, we do a *monolithic* build, which means all the
157 # test suites are baked into the cabal binary
158 timed cabal new-build $jobs $CABAL_INSTALL_FLAGS cabal-install:cabal
160 timed cabal new-build $jobs hackage-repo-tool
162 if [ "x$SKIP_TESTS" = "xYES" ]; then
163 exit 1;
166 # Haddock
167 # TODO: Figure out why this needs to be run before big tests
168 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
169 (cd cabal-install && timed ${CABAL_INSTALL_SETUP} haddock --builddir=${CABAL_INSTALL_BDIR} ) || exit $?
172 # Tests need this
173 timed ${CABAL_INSTALL_BDIR}/build/cabal/cabal update
175 # Big tests
176 (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 $?
178 (cd cabal-install && timed cabal check) || exit $?
180 if [ "x$TEST_SOLVER_BENCHMARKS" = "xYES" ]; then
181 timed cabal new-build $jobs solver-benchmarks:hackage-benchmark solver-benchmarks:unit-tests
182 timed ${SOLVER_BENCHMARKS_BDIR}/c/unit-tests/build/unit-tests/unit-tests $TEST_OPTIONS
185 unset CABAL_BUILDDIR
187 # Check what we got
188 ${CABAL_INSTALL_BDIR}/build/cabal/cabal --version
190 # If this fails, we WANT to fail, because the tests will not be running then
191 (timed ./travis/upload.sh) || exit $?