Merge pull request #4679
[cabal.git] / travis-common.sh
blobb8996eb3634722c864c40fc1589e201f8d388594
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 HACKAGE_REPO_TOOL_BDIR="${TRAVIS_BUILD_DIR}/dist-newstyle/build/$ARCH/ghc-$GHCVER/hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}/c/hackage-repo-tool"
20 # ---------------------------------------------------------------------
21 # Timing / diagnostic output
22 # ---------------------------------------------------------------------
24 JOB_START_TIME=$(date +%s)
26 timed() {
27 echo "\$ $*"
28 start_time=$(date +%s)
30 # Run the job
31 $* || exit $?
33 # Calculate the durations
34 end_time=$(date +%s)
35 duration=$((end_time - start_time))
36 total_duration=$((end_time - JOB_START_TIME))
38 # Print them
39 echo "$* took $duration seconds."
40 echo "whole job took $total_duration seconds so far."
42 # Terminate on OSX
43 if [ $total_duration -ge 2400 -a $(uname) = "Darwin" ]; then
44 echo "Job taking over 40 minutes. Terminating"
45 exit 1
47 echo "----"
50 travis_retry () {
51 $* || (sleep 1 && $*) || (sleep 2 && $*)