#!/bin/bash

# Test script for multiple XGBoost versions

# Versions to test
VERSIONS=(
    "1.4.2"   # First with thread-safe predictions
    "1.7.6"   # Last of 1.x series
    "2.0.3"   # 2.x series
    "2.1.4"   # Last of 2.x series
    "3.0.5"   # 3.x series
    "3.1.1"   # Latest
)

echo "Testing XGBoost Rust bindings with multiple versions"
echo "====================================================="
echo ""

# Clean once before starting
echo "Cleaning build artifacts..."
cargo clean
echo ""

for version in "${VERSIONS[@]}"; do
    echo "----------------------------------------"
    echo "Testing XGBoost version: $version"
    echo "----------------------------------------"

    # Set version environment variable
    export XGBOOST_VERSION=$version

    # Try to build
    echo "Running: XGBOOST_VERSION=$version cargo check"
    if cargo check 2>&1 | grep -E "(Finished|error|Failed)"; then
        echo "✓ Version $version: Build check completed"
    else
        echo "✗ Version $version: Build check had issues"
    fi

    echo ""

    # Clean between versions to force re-download
    cargo clean
done

echo "========================================"
echo "Version testing complete!"
echo "========================================"
