language: cpp
cache: ccache
sudo: required
dist: trusty
env:
 - TEST_SUITE=user CMAKE_FLAGS=
 - TEST_SUITE=root CMAKE_FLAGS=-DWITH_DOC=OFF
before_install:
 - sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ wily main universe' -y
 - sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ xenial main' -y
 - |
   sudo sh -c '/bin/echo -e "Package: *\nPin: release n=wily\nPin-Priority: 1" > /etc/apt/preferences.d/wily'
   sudo sh -c '/bin/echo -e "Package: *\nPin: release n=xenial\nPin-Priority: 1" > /etc/apt/preferences.d/xenial'
 - sudo apt-get update -qq
install:
 - sudo apt-get -qq -y -t wily install gettext liblz4-dev python3-apt
 - sudo apt-get -qq -y -t xenial install cmake ninja-build
 - sudo ./prepare-release travis-ci
before_script:
 - ( mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Coverage -G Ninja $CMAKE_FLAGS .. )
 - ninja -C build
script:
 - CTEST_OUTPUT_ON_FAILURE=1 ninja -C build test
 - DESTDIR=$PWD/rootdir chronic ninja -C build install
 - test "$TEST_SUITE" != "user"  || ./test/integration/run-tests -qq
 - sudo adduser --force-badname --system --home /nonexistent --no-create-home --quiet _apt || true
 - sudo chmod  go+x /home/travis
 - sudo chmod -R go+rwX /home/travis/build
 - test "$TEST_SUITE" != "root" || sudo ./test/integration/run-tests -qq
after_script:
 - cd build
 - gcov -r $(find -name '*.gcno')
 - bash <(curl -s https://codecov.io/bash)