run_tests.sh
#!/bin/bash
# Mirage Rust test runner script

echo "Mirage Rust Test Runner"
echo "----------------------------------------"

# Check if Docker is installed
if ! command -v docker &> /dev/null; then
    echo "Error: Docker is not installed or not in PATH"
    exit 1
fi

# Check for Windows containers if on Windows
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
    echo "Windows detected, checking Docker container mode..."
    
    # Check if Docker is running in Windows container mode
    if ! docker info | grep -q "windows"; then
        echo "Error: Docker is not running in Windows container mode"
        echo "Please switch Docker to Windows containers before running tests"
        exit 1
    fi
fi

# Build and start the Docker test environment
echo "Building Docker test environment..."
docker-compose build

echo "Starting tests in Docker container..."
docker-compose up --abort-on-container-exit

# Check the exit code
TEST_EXIT_CODE=$?

if [ $TEST_EXIT_CODE -eq 0 ]; then
    echo "----------------------------------------"
    echo "✅ All tests passed!"
    echo "The Rust port of Mirage is functioning correctly"
else
    echo "----------------------------------------"
    echo "❌ Tests failed with exit code $TEST_EXIT_CODE"
    echo "Please check the Docker container logs for details"
fi

# Clean up
echo "Cleaning up Docker containers..."
docker-compose down

exit $TEST_EXIT_CODE