# we want to use our custom environment, but the Travis YAML validator
# requires this field to be specified, so we'll just use 'c'
language: c
env:
 # we have to use CABALVER=1.16 for GHC<7.6 as well, as there's
 # no package for earlier cabal versions in the PPA
 - GHCVER=7.4.1 CABALVER=1.16
 - GHCVER=7.4.2 CABALVER=1.16
 - GHCVER=7.6.3 CABALVER=1.16
 - GHCVER=7.8.3 CABALVER=1.18
 - GHCVER=head  CABALVER=head

matrix:
  allow_failures:
   - env: GHCVER=head  CABALVER=head

before_install:
 - travis_retry sudo add-apt-repository -y ppa:hvr/ghc
 - travis_retry sudo apt-get update
 - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
 - cabal --version

install:
 - travis_retry cabal update
 - cabal install --enable-tests --only-dependencies
 - ghc --version

before_script:
 - | # check if 'streaming' is supported (didn't exist until 1.20)
     if cabal 2>&1 test --show-details=streaming __dummy |
        grep >/dev/null 2>&1 "cabal: --show-details flag expects"
     then streaming=always
     else streaming=streaming
     fi
     export streaming

script:
 - autoreconf -i
 - cabal configure -v2 --enable-tests
 - cabal build
 - cabal check
 - cabal sdist
 - cabal test --show-details=$streaming
 - | # in the future, use '--run-tests' (didn't exist until 1.20)
     cabal install --force-reinstalls dist/*-*.tar.gz
     mkdir install-tmp
     cd install-tmp
     tar xzf ../dist/*-*.tar.gz
     cd *-*
     cabal configure --enable-tests
     cabal build
     cabal test
