#!/bin/bash
# Run all 4 AI collation engines in parallel and display results.
# Usage: ./run-all-tests.sh [--data=test-data-file.json]

TESTS_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$TESTS_DIR")"
DATA_FLAG=""

for arg in "$@"; do
    if [[ "$arg" == --data=* ]]; then
        DATA_FLAG="$arg"
    fi
done

cd "$PROJECT_DIR" || exit 1

echo "Running all 4 engines in parallel..."
echo "Data: ${DATA_FLAG:-test-data.json (default)}"
echo ""

python3.8 tests/test_engines.py claude claude-opus-4-20250514 $DATA_FLAG > tests/log/claude/stdout.txt 2>&1 &
PID_CLAUDE=$!

python3.8 tests/test_engines.py openai gpt-5.4 $DATA_FLAG > tests/log/openai/stdout.txt 2>&1 &
PID_OPENAI=$!

python3.8 tests/test_engines.py gemini gemini-3.1-pro-preview $DATA_FLAG > tests/log/gemini/stdout.txt 2>&1 &
PID_GEMINI=$!

python3.8 tests/test_engines.py xai grok-4.20-beta-0309-reasoning $DATA_FLAG > tests/log/xai/stdout.txt 2>&1 &
PID_XAI=$!

# Wait for all and report as they finish
for engine in claude openai gemini xai; do
    eval "wait \$PID_$(echo $engine | tr '[:lower:]' '[:upper:]')"
    echo "=== $engine ==="
    cat "tests/log/$engine/stdout.txt"
    echo ""
done
