#!/usr/bin/env bash
set -euo pipefail
export PATH="$HOME/.cargo/bin:$HOME/.elan/bin:$PATH"
cd "$(dirname "$0")"

cargo test --quiet
cargo run --quiet --release -- fixtures/classic_k5.txt
cargo run --quiet --release -- --verify-small-census
grep -q '^PASS:' <(python3 cross_validate.py fixtures/classic_k5.txt)

if cargo run --quiet --release -- fixtures/noncover.txt >/dev/null 2>&1; then
  echo 'FAIL: Rust checker accepted a non-cover' >&2
  exit 1
fi
if cargo run --quiet --release -- fixtures/reducible_extension.txt >/dev/null 2>&1; then
  echo 'FAIL: Rust checker accepted a reducible set' >&2
  exit 1
fi
if python3 cross_validate.py fixtures/reducible_extension.txt >/dev/null 2>&1; then
  echo 'FAIL: Python checker accepted a reducible set' >&2
  exit 1
fi

echo 'PASS: checker self-tests and independent cross-validation'
