#!/bin/sh # Runs every headless test suite. Fails if any suite fails OR prints a script # error (a script that fails to compile can otherwise let a suite "pass"). # Usage: tests/run_all.sh (from the repo root; needs `godot` on PATH) cd "$(dirname "$0")/.." || exit 1 status=0 # A fresh clone has no class cache yet (.godot/ isn't in git): import once. if [ ! -f .godot/global_script_class_cache.cfg ]; then echo "Importing the project first (fresh copy)..." godot --headless --path . --import >/dev/null 2>&1 fi for t in test_survival_core test_survival_stats test_save_load test_weather_building test_creatures_combat test_wolves test_alpha test_bear test_thieves test_barrow test_boss test_den_sites test_fishing_diet test_food test_hazards test_iron test_stone test_net_lobby test_net_world test_net_shared test_net_life test_net_boss test_net_rules test_net_lands test_host test_tutorial test_tutorial_full test_hints test_updates test_audio test_items_more test_worldlets test_worldlet_pick test_water_bodies test_cove test_wreck test_shore test_boat test_tunnel test_map test_terrain_edges test_boundary; do extra="" [ "$t" = "test_boundary" ] && extra="--fixed-fps 30" # A suite that waits on a world that failed to load would hang forever, # so give each one a time limit when `timeout` is available. limit="" command -v timeout >/dev/null 2>&1 && limit="timeout 300" out=$($limit godot --headless --path . $extra --script "res://tests/$t.gd" 2>&1) code=$? result=$(printf '%s\n' "$out" | grep "RESULT:" | tail -n 1) if [ $code -ne 0 ] || printf '%s\n' "$out" | grep -q "SCRIPT ERROR"; then echo "FAIL $t $result" printf '%s\n' "$out" | grep -E "FAIL|SCRIPT ERROR|at: " | head -n 20 # The whole output, for failures that don't happen twice. mkdir -p build/test-logs printf '%s\n' "$out" > "build/test-logs/$t.log" echo " (full output: build/test-logs/$t.log)" status=1 else echo "ok $t $result" fi done exit $status