---
language: c
matrix:
  fast_finish: true
  include:
  - os: linux
    dist: xenial
    compiler: gcc
  - os: linux
    dist: xenial
    compiler: clang
  - os: linux
    dist: xenial
    compiler: clang
    env: SAN_FLAGS="--enable-asan --enable-ubsan"
  - os: osx
    osx_image: xcode10.1
    compiler: clang
  allow_failures:
  - os: osx
  - env: SAN_FLAGS="--enable-asan --enable-ubsan"
addons:
  apt:
    packages:
      - python-docutils
      - python-sphinx
  homebrew:
    packages:
      - docutils
      - nghttp2
      - sphinx-doc
notifications:
  irc:
    channels:
      - "irc.linpro.no#varnish-hacking"
    on_success: change
    use_notice: true
before_install:
  - |
    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"
    elif [[ -n "$SAN_FLAGS" ]]; then
      export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage ${SAN_FLAGS}"
      export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0
      export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr
      export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr
      export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr
    fi
  - ./autogen.sh
  - ./configure ${CONFIGURE_ARGS}
script:
  - |
    if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
      make -j3 distcheck
    else
      make -j3 check VERBOSE=1
    fi
