#!/bin/bash # Test scope enforcement for MiniMax agents. # Prevents running the full test suite — only allows specific test files. # Usage: ./run-tests.sh tests/test_my_feature.py set -euo pipefail if [ $# -eq 0 ]; then echo "ERROR: Specify a test file. Usage: ./run-tests.sh tests/test_YOUR_FILE.py" >&2 echo "Do NOT run the full test suite." >&2 exit 1 fi TEST_PATH="$1" shift # Block full-suite patterns case "$TEST_PATH" in tests/|tests|.) echo "ERROR: Running the full test suite is not allowed." >&2 echo "Specify a single test file: ./run-tests.sh tests/test_YOUR_FILE.py" >&2 exit 1 ;; esac # Must be a .py file in tests/ if [[ ! "$TEST_PATH" =~ ^tests/test_.*\.py$ ]]; then echo "ERROR: Test path must match tests/test_*.py (got: $TEST_PATH)" >&2 exit 1 fi echo "Running: python -m pytest $TEST_PATH -v --tb=short -x $*" exec python -m pytest "$TEST_PATH" -v --tb=short -x "$@"