Merge pull request #5602 from fgaz/new-install/warn-symlink
[cabal.git] / travis-script.sh
blobc7a7b614dca52d4e8e85432efcc97c8a88168aa6
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 make cabal-install-monolithic
85 cp cabal.project.travis cabal.project.local
87 # hackage-repo-tool is a bit touchy to install on GHC 8.0, so instead we
88 # do it via new-build. See also cabal.project.travis. The downside of
89 # doing it this way is that the build product cannot be cached, but
90 # hackage-repo-tool is a relatively small package so it's good.
91 timed cabal unpack hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}
93 # ---------------------------------------------------------------------
94 # Cabal
95 # ---------------------------------------------------------------------
97 # Needed to work around some bugs in nix-local-build code.
98 export CABAL_BUILDDIR="${CABAL_BDIR}"
100 if [ "x$CABAL_INSTALL_ONLY" != "xYES" ] ; then
101 # We're doing a full build and test of Cabal
103 # NB: Best to do everything for a single package together as it's
104 # more efficient (since new-build will uselessly try to rebuild
105 # Cabal otherwise).
106 timed cabal new-build $jobs Cabal Cabal:unit-tests Cabal:check-tests Cabal:parser-tests Cabal:hackage-tests --enable-tests
108 # Run haddock.
109 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
110 # TODO: use new-haddock?
111 (cd Cabal && timed cabal act-as-setup --build-type=Simple -- haddock --builddir=${CABAL_BDIR}) || exit $?
114 # Check for package warnings
115 (cd Cabal && timed cabal check) || exit $?
118 unset CABAL_BUILDDIR
120 # Build and run the package tests
122 export CABAL_BUILDDIR="${CABAL_TESTSUITE_BDIR}"
124 # NB: We always build this test runner, because it is used
125 # both by Cabal and cabal-install
126 timed cabal new-build $jobs cabal-testsuite:cabal-tests
128 if [ "x$SKIP_TESTS" != "xYES" ]; then
129 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} -j3 $TEST_OPTIONS) || exit $?
132 # Redo the package tests with different versions of GHC
133 if [ "x$TEST_OTHER_VERSIONS" = "xYES" ]; then
134 (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")
135 (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")
136 (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")
139 unset CABAL_BUILDDIR
141 if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then
142 # If this fails, we WANT to fail, because the tests will not be running then
143 (timed ./travis/upload.sh) || exit $?
144 exit 0;
147 # ---------------------------------------------------------------------
148 # cabal-install
149 # ---------------------------------------------------------------------
151 # Needed to work around some bugs in nix-local-build code.
152 export CABAL_BUILDDIR="${CABAL_INSTALL_BDIR}"
154 if [ "x$DEBUG_EXPENSIVE_ASSERTIONS" = "xYES" ]; then
155 CABAL_INSTALL_FLAGS=-fdebug-expensive-assertions
158 # NB: For Travis, we do a *monolithic* build, which means all the
159 # test suites are baked into the cabal binary
160 timed cabal new-build $jobs $CABAL_INSTALL_FLAGS cabal-install:cabal
162 timed cabal new-build $jobs hackage-repo-tool
164 if [ "x$SKIP_TESTS" = "xYES" ]; then
165 exit 1;
168 # Tests need this
169 timed ${CABAL_INSTALL_EXE} update
171 # Big tests
172 (cd cabal-testsuite && timed ${CABAL_TESTSUITE_BDIR}/build/cabal-tests/cabal-tests --builddir=${CABAL_TESTSUITE_BDIR} -j3 --skip-setup-tests --with-cabal ${CABAL_INSTALL_EXE} --with-hackage-repo-tool ${HACKAGE_REPO_TOOL_BDIR}/build/hackage-repo-tool/hackage-repo-tool $TEST_OPTIONS) || exit $?
174 # Cabal check
175 # TODO: remove -main-is and re-enable me.
176 # (cd cabal-install && timed cabal check) || exit $?
178 if [ "x$TEST_SOLVER_BENCHMARKS" = "xYES" ]; then
179 timed cabal new-build $jobs solver-benchmarks:hackage-benchmark solver-benchmarks:unit-tests
180 timed ${SOLVER_BENCHMARKS_BDIR}/c/unit-tests/build/unit-tests/unit-tests $TEST_OPTIONS
183 # Haddock
184 # TODO: >= 8.4.3 would be nicer
185 if [ "$TRAVIS_OS_NAME" = "linux" -a "$GHCVER" == "8.4.3" ]; then
186 timed cabal new-haddock cabal-install
189 unset CABAL_BUILDDIR
191 # Check what we got
192 ${CABAL_INSTALL_EXE} --version
194 # If this fails, we WANT to fail, because the tests will not be running then
195 (timed ./travis/upload.sh) || exit $?