#!/usr/bin/env bash
# Test script for Lumacs

set -e

echo "Running Lumacs tests..."

# Build first if needed
if [ ! -f "build/lumacs" ]; then
    echo "Binary not found, building first..."
    ./scripts/build.sh
fi

# Run unit tests
echo "Running unit tests with CTest..."
ctest --test-dir build

# Test basic functionality
echo "Testing basic functionality..."

# Test with example file
if [ -f "examples/test_dracula_simple.cpp" ]; then
    echo "Testing with example C++ file..."
    timeout 3s ./build/lumacs examples/test_dracula_simple.cpp || echo "Editor test completed (timeout expected)"
fi

echo "✓ Tests completed!"