#!/bin/sh
# Run the same pinned lint gate as CI, then the sandboxed test suite.
set -eu
cd -- "$(dirname -- "$0")/.."
if [ -n "${PYTHON:-}" ]; then
    python_bin=$PYTHON
elif [ -x .venv/bin/python ]; then
    python_bin=.venv/bin/python
else
    python_bin=python3
fi
ruff_version=0.16.10
if "$python_bin" -c 'import importlib.metadata as m, sys; sys.exit(m.version("ruff") != sys.argv[1])' "$ruff_version" 2>/dev/null; then
    "$python_bin" -m ruff check src tests
elif command -v uvx >/dev/null 2>&1; then
    uvx "ruff@$ruff_version" check src tests
else
    echo "Pinned Ruff $ruff_version is missing; run ./scripts/setup-dev first." >&2
    exit 127
fi
"$python_bin" -m pytest -q "$@"
