#!/bin/bash # GAL Regression Test - Master Script # ==================================== # Single script to build, run, and compare native OpenGL and WebGL GAL implementations. # # Two-level comparison: # 1. native vs baseline - Catches if native code regressed # 2. webgl vs native - Verifies WebGL implementation matches native # # Usage: # ./scripts/test-gal-regression.sh # Run all tests # ./scripts/test-gal-regression.sh native # Run native only # ./scripts/test-gal-regression.sh webgl # Run webgl only (requires native output) # ./scripts/test-gal-regression.sh compare # Compare only (skip builds) # ./scripts/test-gal-regression.sh -v # Verbose output # Redirect all output to a log file (re-execs script with redirection) source "$(dirname "$0")/common/logging.sh" set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # Directories GAL_REGRESSION_DIR="$PROJECT_ROOT/tests/gal-regression" BASELINE_DIR="$GAL_REGRESSION_DIR/baseline" OUTPUT_DIR="$GAL_REGRESSION_DIR/output" NATIVE_OUTPUT_DIR="$OUTPUT_DIR/native" WEBGL_OUTPUT_DIR="$OUTPUT_DIR/webgl" NATIVE_BUILD_DIR="$GAL_REGRESSION_DIR/native/build" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Parse arguments VERBOSE="" RUN_NATIVE=true RUN_WEBGL=true COMPARE_ONLY=false for arg in "$@"; do case $arg in native) RUN_WEBGL=false ;; webgl) RUN_NATIVE=false ;; compare) COMPARE_ONLY=true ;; -v|--verbose) VERBOSE="-v" ;; esac done # ============================================================================ # Helper Functions # ============================================================================ log_header() { echo "" echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}" echo -e "${BLUE} $1${NC}" echo -e "${BLUE}════════════════════════════════════════════════════════════════${NC}" } log_step() { echo -e "${YELLOW}>>> $1${NC}" } log_success() { echo -e "${GREEN}✓ $1${NC}" } log_error() { echo -e "${RED}✗ $1${NC}" } # Compare two directories of screenshots # Usage: compare_screenshots