coverage_testscenes.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 and the light kind variants from make_light_scenes.py, both made here) 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. [ -d "$TESTS/volshadow/point" ] && python3 -I "$HERE/analysis/make_light_scenes.py" "$TESTS/volshadow/point" "$TESTS/lights"
  16. [ -d "$TESTS/texanim/probe" ] && python3 -I "$HERE/analysis/make_texanim_reverse.py" "$TESTS/texanim/probe" "$TESTS/texanim-reverse"
  17. work=$(mktemp -d /tmp/lwe-coverage-testscenes.XXXXXX)
  18. trap 'rm -rf "$work"' EXIT
  19. export SDL_AUDIODRIVER=disk SDL_DISKAUDIOFILE=/dev/null PULSE_SERVER=unix:/nonexistent PIPEWIRE_REMOTE=/nonexistent
  20. ok=0
  21. bad=0
  22. while read -r project; do
  23. folder=$(dirname "$project")
  24. if HEADLESS_RENDER_DELAY=60 HEADLESS_RENDER_TIMEOUT=90 HEADLESS_RENDER_SIZE=800x450 \
  25. "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" --assets-dir "$ASSETS" "$folder" > "$work/run.log" 2>&1; then
  26. ok=$((ok + 1))
  27. else
  28. bad=$((bad + 1))
  29. echo "FAIL ${folder#"$TESTS"/}: $(tail -1 "$work/run.log" | cut -c1-120)"
  30. fi
  31. rm -f "$work/shot.png"
  32. done < <(find "$TESTS" "$ASSETS/effects" "$ASSETS/presets" "$ASSETS/scenes" -name project.json 2>/dev/null | sort)
  33. echo "rendered $ok, failed $bad"