Fix Cabal parser tests now that buildDepends is no longer a field
[cabal.git] / travis-common.sh
blob264c21f308b74879b74a0fa9b8aba74e0415f29c
1 set -e
3 HACKAGE_REPO_TOOL_VERSION="0.1.1"
4 CABAL_VERSION="2.1.0.0"
6 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
7 ARCH="x86_64-linux"
8 else
9 ARCH="x86_64-osx"
12 CABAL_STORE_DB="${HOME}/.cabal/store/ghc-${GHCVER}/package.db"
13 CABAL_LOCAL_DB="${TRAVIS_BUILD_DIR}/dist-newstyle/packagedb/ghc-${GHCVER}"
14 CABAL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/Cabal-${CABAL_VERSION}"
15 CABAL_TESTSUITE_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/cabal-testsuite-${CABAL_VERSION}"
16 CABAL_INSTALL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/cabal-install-${CABAL_VERSION}"
17 CABAL_INSTALL_SETUP="${CABAL_INSTALL_BDIR}/setup/setup"
18 SOLVER_BENCHMARKS_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/solver-benchmarks-${CABAL_VERSION}"
19 HACKAGE_REPO_TOOL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}/c/hackage-repo-tool"
21 # ---------------------------------------------------------------------
22 # Timing / diagnostic output
23 # ---------------------------------------------------------------------
25 JOB_START_TIME=$(date +%s)
27 timed() {
28 echo "\$ $*"
29 start_time=$(date +%s)
31 # Run the job
32 $* || exit $?
34 # Calculate the durations
35 end_time=$(date +%s)
36 duration=$((end_time - start_time))
37 total_duration=$((end_time - JOB_START_TIME))
39 # Print them
40 echo "$* took $duration seconds."
41 echo "whole job took $total_duration seconds so far."
43 # Terminate if the job is taking too long (we must do this to
44 # preserve the populated cache for the next run).
45 if [ $total_duration -ge 2400 ]; then
46 echo "Job taking over 38 minutes. Terminating"
47 exit 1
49 echo "----"
52 travis_retry () {
53 $* || (sleep 1 && $*) || (sleep 2 && $*)