1#!/bin/bash 2# 3# Copyright 2016, NICTA 4# 5# This software may be distributed and modified according to the terms of 6# the GNU General Public License version 2. Note that NO WARRANTY is provided. 7# See "LICENSE_GPLv2.txt" for details. 8# 9# @TAG(NICTA_GPL) 10# 11 12# 7.8.3 doesn't work well any longer 13# 7.8.4 is the default compiler, so not tested here 14# The following are the 'extra' versions that we support 15GHC_VERSIONS=('7.10.1' '7.10.2' '7.10.3') 16UNAME=`uname | tr [A-Z] [a-z]` 17ARCH="`arch`-${UNAME}" 18 19declare -i tests=0 passed=0 20 21echo `cabal --version` 22 23echo "\$PATH is $PATH" 24 25for i in ${GHC_VERSIONS[@]}; do 26 tests+=1 27 echo "***** Compiling with GHC ${i} *****" 28 29 if ! which "ghc-${i}"; then 30 echo "ghc-${i} not found, skip!" 31 continue 32 fi 33 34 export GHC="ghc-${i}" 35 export HC_PKG="ghc-pkg-${i}" 36 export DIST="dist-${i}" 37 export ARCH="$ARCH" 38 export GHC_VER="${i}" 39 export PACKAGE_DB=".cabal-sandbox/${ARCH}-${GHC}-packages.conf.d" 40 41 # check if the new dep is the same as old 42 cabal install --upgrade-dependencies --dry-run --only-dependencies \ 43 --with-compiler="ghc-${i}" --with-hc-pkg="ghc-pkg-${i}" \ 44 --package-db="$PACKAGE_DB" > "$0.tmp" 45 if grep -q "^All the requested packages are already installed:" "$0.tmp" # nothing changed 46 then cabal install --upgrade-dependencies \ 47 --with-compiler="ghc-${i}" --with-hc-pkg="ghc-pkg-${i}" --package-db=$PACKAGE_DB 48 if [[ $? -eq 0 ]]; then 49 echo "PASSED with GHC ${i} without changes" 50 passed+=1 51 echo -n 52 continue 53 fi 54 fi 55 56 # if dep changed, or unchanged but installation failed, then redo from scratch 57 ./validate.sh -update-cabal # -keep-sandbox 58 if [[ $? -eq 0 ]]; then 59 echo "PASSED with GHC ${i} with changes" 60 passed+=1 61 else 62 echo "FAILED with GHC ${i}" 63 fi 64 echo -n 65done 66 67rm -f "$0.tmp" 68 69echo "$passed out of $tests tests passed!" 70 71if [[ $passed -lt $tests ]]; then 72 exit 1 73fi 74 75