#!/usr/bin/env bash
set -aeuf -o pipefail

# Run doc build
#DISABLE_DOC_BUILD=1

# Enable backtrace on testing/example failure?
#RUST_BACKTRACE=1

## Force all features to exercise all paths and be verbose about it.
CARGO_ARGS="--verbose --all-features"

## Simple check to fast-fail
cargo check ${CARGO_ARGS}

##############################################################################
# FULL BUILD/TEST
##############################################################################

## Perform the standard build/test
cargo build ${CARGO_ARGS}
cargo test ${CARGO_ARGS}

##############################################################################
# DOC BUILD
##############################################################################

## Build docs to make sure no surprises.
if [[ -z "${DISABLE_DOC_BUILD:-}" ]]; then
  echo "WARNING: Skipping docs build."
else
  cargo doc --no-deps ${CARGO_ARGS}
fi
