#!/bin/bash # Run Aniworld Robot Framework tests on Unix/Linux/macOS # Usage: ./run.sh [suite_pattern] # Examples: # ./run.sh # Run all tests # ./run.sh api/auth.robot # Run specific suite # ./run.sh ui/ # Run all UI tests set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROBOT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_DIR="$(dirname "$ROBOT_DIR")" RESULTS_DIR="$ROBOT_DIR/results" # Default: run everything SUITE_PATTERN="${1:-tests/robot/}" echo "========================================" echo "Aniworld Robot Framework Test Runner" echo "========================================" echo "Project dir: $PROJECT_DIR" echo "Results dir: $RESULTS_DIR" echo "Suite pattern: $SUITE_PATTERN" echo "" # Ensure we're in the project directory cd "$PROJECT_DIR" # Check Python environment if ! command -v python >/dev/null 2>&1; then echo "Error: python not found in PATH" exit 1 fi # Install/update Robot Framework dependencies echo "Installing Robot Framework dependencies..." pip install -q robotframework robotframework-browser robotframework-requests robotframework-jsonlibrary 2>/dev/null || true # Initialize Browser library (Playwright) echo "Initializing Browser library (Playwright)..." python -m Browser.entry init 2>/dev/null || rfbrowser init 2>/dev/null || echo "Warning: Browser library init may need manual run: 'rfbrowser init'" # Create results directory mkdir -p "$RESULTS_DIR" # Run tests echo "" echo "Running Robot Framework tests..." echo "----------------------------------------" robot \ --outputdir "$RESULTS_DIR" \ --logtitle "Aniworld Test Log" \ --reporttitle "Aniworld Test Report" \ --metadata Project:Aniworld \ --metadata Environment:"$(python --version 2>&1)" \ --variable BASE_URL:http://127.0.0.1:8765 \ --variable BROWSER:chromium \ --variable HEADLESS:True \ "$SUITE_PATTERN" EXIT_CODE=$? echo "" echo "========================================" if [ $EXIT_CODE -eq 0 ]; then echo "All tests PASSED" else echo "Some tests FAILED (exit code: $EXIT_CODE)" fi echo "Report: $RESULTS_DIR/report.html" echo "Log: $RESULTS_DIR/log.html" echo "Output: $RESULTS_DIR/output.xml" echo "========================================" exit $EXIT_CODE