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
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
16 # --hide-successes uses terminal control characters which mess up
17 # Travis's log viewer. So just print them all!
20 # To be enabled temporarily when you need to pre-populate the Travis
21 # cache to avoid timeout.
24 # ---------------------------------------------------------------------
26 # ---------------------------------------------------------------------
29 echo -e -n "Usage: `basename $0`\n-j jobs\n"
33 while getopts ":hj:" opt
; do
44 if [ "$OPTARG" = "j" ]; then
49 echo "Invalid option: $OPTARG"
57 # Do not try to use -j with GHC older than 7.8
66 # ---------------------------------------------------------------------
67 # Update the Cabal index
68 # ---------------------------------------------------------------------
72 # ---------------------------------------------------------------------
73 # Install executables if necessary
74 # ---------------------------------------------------------------------
76 if ! command -v happy
; then
77 timed cabal
install $jobs happy
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 # ---------------------------------------------------------------------
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
105 timed cabal new-build
$jobs Cabal Cabal
:unit-tests Cabal
:check-tests Cabal
:parser-tests Cabal
:parser-hackage-tests
--enable-tests
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 $?
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 if [ "x$SKIP_TESTS" != "xYES" ]; then
125 (cd cabal-testsuite
&& timed
${CABAL_TESTSUITE_BDIR}/build
/cabal-tests
/cabal-tests
--builddir=${CABAL_TESTSUITE_BDIR} -j3 $TEST_OPTIONS) ||
exit $?
128 # Redo the package tests with different versions of GHC
129 if [ "x$TEST_OTHER_VERSIONS" = "xYES" ]; then
130 (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")
131 (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")
132 (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 if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then
138 # If this fails, we WANT to fail, because the tests will not be running then
139 (timed .
/travis
/upload.sh
) ||
exit $?
143 # ---------------------------------------------------------------------
145 # ---------------------------------------------------------------------
147 # Needed to work around some bugs in nix-local-build code.
148 export CABAL_BUILDDIR
="${CABAL_INSTALL_BDIR}"
150 if [ "x$DEBUG_EXPENSIVE_ASSERTIONS" = "xYES" ]; then
151 CABAL_INSTALL_FLAGS
=-fdebug-expensive-assertions
154 # NB: For Travis, we do a *monolithic* build, which means all the
155 # test suites are baked into the cabal binary
156 timed cabal new-build
$jobs $CABAL_INSTALL_FLAGS cabal-install
:cabal
158 timed cabal new-build
$jobs hackage-repo-tool
160 if [ "x$SKIP_TESTS" = "xYES" ]; then
165 # TODO: Figure out why this needs to be run before big tests
166 (cd cabal-install
&& timed
${CABAL_INSTALL_SETUP} haddock
--builddir=${CABAL_INSTALL_BDIR} ) ||
exit $?
169 timed
${CABAL_INSTALL_BDIR}/build
/cabal
/cabal update
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_BDIR}/build/cabal/cabal --with-hackage-repo-tool ${HACKAGE_REPO_TOOL_BDIR}/build
/hackage-repo-tool
/hackage-repo-tool
$TEST_OPTIONS) ||
exit $?
174 (cd cabal-install
&& timed cabal check
) ||
exit $?
176 if [ "x$TEST_SOLVER_BENCHMARKS" = "xYES" ]; then
177 timed cabal new-build
$jobs solver-benchmarks
:hackage-benchmark solver-benchmarks
:unit-tests
178 timed
${SOLVER_BENCHMARKS_BDIR}/c
/unit-tests
/build
/unit-tests
/unit-tests
$TEST_OPTIONS
184 ${CABAL_INSTALL_BDIR}/build
/cabal
/cabal
--version
186 # If this fails, we WANT to fail, because the tests will not be running then
187 (timed .
/travis
/upload.sh
) ||
exit $?