language: rust
services: docker
cache:
  - cargo

matrix:
  include:
    - rust: 1.46.0 # MSRV
    - rust: stable
    - rust: beta
    - rust: nightly
    - os: osx
    # Tier 1
    - env: CROSS_TEST=i686-unknown-linux-gnu
    # Tier 2
    - env: CROSS_TEST=aarch64-unknown-linux-gnu
    - env: CROSS_CHECK=wasm32-unknown-unknown

script:
  - |
    set -e
    if [[ "$TRAVIS_RUST_VERSION" == nightly ]]
    then
        # Make sure the benchmarks compile
        cargo build --benches --all

        export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0"
        export RUST_BACKTRACE=1

        # Run address sanitizer
        RUSTFLAGS="-Z sanitizer=address" \
        cargo test --lib --target x86_64-unknown-linux-gnu
    fi
  - |
    set -e
    if [[ "$CROSS_CHECK" ]]
    then
        rustup target add $CROSS_CHECK
        cargo check --target $CROSS_CHECK
        cargo check --target $CROSS_CHECK --no-default-features
    elif [[ "$CROSS_TEST" ]]
    then
        cargo install --force cross
        cross test --target=$CROSS_TEST
        cross check --target $CROSS_TEST --no-default-features
    else
        cargo test --no-fail-fast
        cargo test --no-fail-fast --release
        cargo check --no-default-features
    fi
