39 lines
895 B
Bash
Executable File
39 lines
895 B
Bash
Executable File
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i bash
|
|
#!nix-shell -p python3 python3Packages.click python3Packages.ruff python3Packages.black python3Packages.mypy python3Packages.pytest
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$here"
|
|
|
|
cache_root="${TMPDIR:-/tmp}/mcp-tests-cache"
|
|
mkdir -p "$cache_root"
|
|
export XDG_CACHE_HOME="$cache_root/xdg"
|
|
export RUFF_CACHE_DIR="$cache_root/ruff"
|
|
export MYPY_CACHE_DIR="$cache_root/mypy"
|
|
export PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} -o cache_dir=$cache_root/pytest"
|
|
|
|
fix=false
|
|
for arg in "$@"; do
|
|
if [ "$arg" = "--fix" ]; then
|
|
fix=true
|
|
fi
|
|
done
|
|
if $fix; then
|
|
ruff check --fix .
|
|
black .
|
|
else
|
|
ruff check .
|
|
black --check .
|
|
fi
|
|
mypy src
|
|
|
|
start=$(date +%s)
|
|
pytest
|
|
elapsed=$(( $(date +%s) - start ))
|
|
echo "Test suite duration: ${elapsed}s"
|
|
if [ $elapsed -gt 60 ]; then
|
|
echo "Test suite exceeded 60s budget." >&2
|
|
exit 1
|
|
fi
|