coverage_testscenes.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. # Renders every test scene headlessly with a coverage build, one at a time, for the features the workshop library does
  3. # not use: the generated scenes under a tests dir (default ~/.local/share/we_live/tests, made for the comparisons against
  4. # live Wallpaper Engine: sound, skinned models, ropes, particle trees, shadows, video textures...; the particle
  5. # operator scenes come from tools/analysis/make_particle_scenes.py, made here when the folder is missing) and the preview
  6. # scenes Wallpaper Engine ships in its assets (effects/*/preview, presets, scenes).
  7. # Audio goes to SDL's disk driver and a dead PulseAudio server, never to a real device.
  8. # Usage: tools/analysis/coverage_testscenes.sh <engine binary> [tests dir] [assets dir]
  9. set -uo pipefail
  10. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  11. BINARY=${1:?engine binary}
  12. TESTS=${2:-$HOME/.local/share/we_live/tests}
  13. ASSETS=${3:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  14. python3 -I "$HERE/analysis/make_particle_scenes.py" "$TESTS/particles"
  15. work=$(mktemp -d /tmp/lwe-coverage-testscenes.XXXXXX)
  16. trap 'rm -rf "$work"' EXIT
  17. export SDL_AUDIODRIVER=disk SDL_DISKAUDIOFILE=/dev/null PULSE_SERVER=unix:/nonexistent PIPEWIRE_REMOTE=/nonexistent
  18. ok=0
  19. bad=0
  20. while read -r project; do
  21. folder=$(dirname "$project")
  22. if HEADLESS_RENDER_DELAY=60 HEADLESS_RENDER_TIMEOUT=90 HEADLESS_RENDER_SIZE=800x450 \
  23. "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" --assets-dir "$ASSETS" "$folder" > "$work/run.log" 2>&1; then
  24. ok=$((ok + 1))
  25. else
  26. bad=$((bad + 1))
  27. echo "FAIL ${folder#"$TESTS"/}: $(tail -1 "$work/run.log" | cut -c1-120)"
  28. fi
  29. rm -f "$work/shot.png"
  30. done < <(find "$TESTS" "$ASSETS/effects" "$ASSETS/presets" "$ASSETS/scenes" -name project.json 2>/dev/null | sort)
  31. echo "rendered $ok, failed $bad"