handwriting-ocr / test_local.sh
Raymond Weitekamp
feat: add HF authentication setup and testing infrastructure - Add save_hf_storage_state.py for auth state management - Add check_hf_login.py for login verification - Update test_local.sh with Playwright setup - Add .cursor rules for test-first development - Update requirements.txt with new dependencies
fcd4d8a
#!/bin/bash
# Exit on error
set -e
# Kill any existing processes using port 7862
echo "Cleaning up port 7862..."
lsof -ti:7862 | xargs kill -9 2>/dev/null || true
# Check if uv is installed, if not install it
if ! command -v uv &> /dev/null; then
echo "Installing uv package installer..."
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python -m venv venv
fi
# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate
# Install dependencies using uv
echo "Installing dependencies with uv..."
uv pip install -r requirements.txt
# Install Playwright browsers
echo "Installing Playwright browsers..."
playwright install chromium
# Run unit tests
echo "Running unit tests..."
python -m pytest test_app.py -v
if [ $? -eq 0 ]; then
echo "Unit tests passed! Starting Gradio app..."
# Start Gradio app in background
python app.py &
GRADIO_PID=$!
# Wait for server to start
echo "Waiting for Gradio server to start..."
sleep 3
# Run e2e tests
echo "Running e2e tests..."
python -m pytest test_e2e.py -v
E2E_STATUS=$?
# Kill Gradio server
kill $GRADIO_PID
if [ $E2E_STATUS -eq 0 ]; then
echo "All tests passed!"
exit 0
else
echo "E2E tests failed! Please fix the issues before running the app."
exit 1
fi
else
echo "Unit tests failed! Please fix the issues before running e2e tests."
exit 1
fi
# Deactivate virtual environment
deactivate