#!/bin/sh
#
# Pre-commit hook: runs fast tests, clippy, and format check
# Full test suite (including slow tests) runs in CI
#
# MAINTAINER NOTE: If you add new slow tests (>5s), add them to --skip below.
# Current skips: stress (fuzz tests ~80s), citylots (large data ~10s), regexp_validity (~8s)
#

set -e

echo '+cargo test --lib (output suppressed unless failure)'
TEST_OUTPUT=$(cargo test --lib -- --skip stress --skip citylots --skip regexp_validity --test-threads=1 2>&1) || {
    echo "$TEST_OUTPUT"
    exit 1
}
echo "$TEST_OUTPUT" | grep -E '^test result:'

echo '+cargo clippy --all-targets --all-features -- -D warnings'
cargo clippy --all-targets --all-features -- -D warnings

echo '+cargo fmt -- --check'
cargo fmt -- --check
