#!/bin/sh
# The slow checks: every doctest links its own binary, and rustdoc is its own pass.
#
# Measured on a warm tree: about a second and a half for all three. One of the tests reads
# the grid fixture, so this is also what catches a fixture regenerated but not committed.
#
# Silent when everything passes.
set -e

check() {
    name=$1
    shift
    if ! output=$("$@" 2>&1); then
        echo "pre-push: $name failed" >&2
        printf '%s\n' "$output" >&2
        exit 1
    fi
}

check "the tests" cargo test --workspace
check "the tests without default features" cargo test --no-default-features
# Every target, not only the tests: an example or a benchmark that needs a feature it did
# not declare compiles fine by default and fails only here.
check "every target without default features" cargo build --no-default-features --all-targets
check "the docs" cargo doc --no-deps --workspace
