language: rust
os:
  - linux
  - windows
  - osx
rust:
  - stable
  - beta
  - nightly
env:
  global:
    - RUST_BACKTRACE=1
    - RUSTFLAGS="-D warnings"
matrix:
  allow_failures:
    - rust: nightly

install:
  - if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add rustfmt; fi
  - if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add clippy; fi

script:
  - if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo fmt -- --check; fi
  - if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo clippy -- -W clippy::all; fi
  - cargo test
  - cargo test --features serde
  - cargo test --no-default-features
  - cargo test --no-default-features --features std
  - cargo test --no-default-features --features alloc
  - cargo test --no-default-features --features serde
  # Validate benches still work.
  - cargo bench --all -- --test
