AeThex-Engine-Core/test_headless.sh

124 lines
3.1 KiB
Bash
Executable file

#!/bin/bash
# Test script for headless editor mode
echo "=== AeThex Headless Editor Mode Test ==="
echo ""
# Check if binary exists
if [ ! -f "engine/bin/aethex.linuxbsd.editor.x86_64" ]; then
echo "❌ Engine binary not found!"
echo "Build it first: cd engine && scons platform=linuxbsd target=editor -j2"
exit 1
fi
echo "✅ Engine binary found"
echo ""
# Start engine in background
echo "🚀 Starting engine in headless mode..."
cd engine
./bin/aethex.linuxbsd.editor.x86_64 --headless-editor > ../headless.log 2>&1 &
ENGINE_PID=$!
cd ..
echo " Engine PID: $ENGINE_PID"
echo " Log file: headless.log"
echo ""
# Wait for engine to start
echo "⏳ Waiting 5 seconds for engine to initialize..."
sleep 5
# Check if process is still running
if ! ps -p $ENGINE_PID > /dev/null; then
echo "❌ Engine process died!"
echo ""
echo "Last 20 lines of log:"
tail -20 headless.log
exit 1
fi
echo "✅ Engine process running"
echo ""
# Test API
echo "📡 Testing StudioBridge API..."
echo ""
# Test 1: Get all node types
echo "Test 1: getAllNodeTypes"
RESULT=$(curl -s -X POST http://localhost:6007/rpc \
-H "Content-Type: application/json" \
-d '{"method":"getAllNodeTypes","params":{}}')
if [[ $RESULT == *"success"* ]]; then
echo "✅ getAllNodeTypes - SUCCESS"
echo " Response: ${RESULT:0:100}..."
else
echo "❌ getAllNodeTypes - FAILED"
echo " Response: $RESULT"
fi
echo ""
# Test 2: Get scene tree
echo "Test 2: getSceneTree"
RESULT=$(curl -s -X POST http://localhost:6007/rpc \
-H "Content-Type: application/json" \
-d '{"method":"getSceneTree","params":{}}')
if [[ $RESULT == *"success"* ]]; then
echo "✅ getSceneTree - SUCCESS"
echo " Response: ${RESULT:0:100}..."
else
echo "❌ getSceneTree - FAILED"
echo " Response: $RESULT"
fi
echo ""
# Test 3: Create a node
echo "Test 3: createNode (Node2D)"
RESULT=$(curl -s -X POST http://localhost:6007/rpc \
-H "Content-Type: application/json" \
-d '{"method":"createNode","params":{"type":"Node2D","name":"TestNode","parent":""}}')
if [[ $RESULT == *"success"* ]]; then
echo "✅ createNode - SUCCESS"
echo " Response: ${RESULT:0:100}..."
else
echo "❌ createNode - FAILED"
echo " Response: $RESULT"
fi
echo ""
# Test 4: List directory
echo "Test 4: listDirectory"
RESULT=$(curl -s -X POST http://localhost:6007/rpc \
-H "Content-Type: application/json" \
-d '{"method":"listDirectory","params":{"path":"res://"}}')
if [[ $RESULT == *"success"* ]]; then
echo "✅ listDirectory - SUCCESS"
echo " Response: ${RESULT:0:100}..."
else
echo "❌ listDirectory - FAILED"
echo " Response: $RESULT"
fi
echo ""
# Cleanup
echo "🧹 Cleaning up..."
kill $ENGINE_PID 2>/dev/null
wait $ENGINE_PID 2>/dev/null
echo " Engine process terminated"
echo ""
echo "=== All Tests Complete ==="
echo ""
echo "Log saved to: headless.log"
echo "Review it for any errors or warnings."
echo ""
echo "Next steps:"
echo "1. Review the API responses above"
echo "2. Start Studio: cd aethex-studio && npm run dev"
echo "3. Connect Studio to engine on localhost:6007"
echo ""