coverage_extras.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # What the unit tests and tools/regression/regress.py (scenes) do not run, for a coverage build: every installed web
  3. # wallpaper (CEF host, HEADLESS_RENDER_WEB=1), the presets (they load their base wallpaper, which can be a web page), the SOG splat item, the video wallpapers and the tools/check_*.sh scripts that drive hotswap, transitions, playlists and splats.
  4. # Runs one at a time. Usage: tools/analysis/coverage_extras.sh <engine binary of the coverage build> [assets] [workshop content]
  5. # Afterwards: gcovr -r . --object-directory <build-cov> --filter 'src/WallpaperEngine/' --exclude 'src/WallpaperEngine/Testing'
  6. set -uo pipefail
  7. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  8. BINARY=${1:?engine binary}
  9. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  10. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  11. work=$(mktemp -d /tmp/lwe-coverage-extras.XXXXXX)
  12. trap 'rm -rf "$work"' EXIT
  13. kinds=$(python3 -I - "$CONTENT" <<'PY'
  14. import glob, json, sys
  15. for path in sorted(glob.glob(sys.argv[1] + '/*/project.json')):
  16. try:
  17. project = json.load(open(path))
  18. except Exception:
  19. continue
  20. kind = str(project.get('type', '')).lower()
  21. if not kind and project.get('preset') is not None and project.get('dependency'):
  22. kind = 'preset'
  23. if kind in ('web', 'video', 'preset'):
  24. print(kind, path.split('/')[-2])
  25. PY
  26. )
  27. while read -r kind id; do
  28. [ -n "$id" ] || continue
  29. env=()
  30. delay=150
  31. if [ "$kind" = web ] || [ "$kind" = preset ]; then env=(HEADLESS_RENDER_WEB=1); delay=700; fi
  32. if env "${env[@]}" HEADLESS_RENDER_DELAY=$delay HEADLESS_RENDER_TIMEOUT=150 HEADLESS_RENDER_SIZE=1280x720 \
  33. "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" --assets-dir "$ASSETS" "$CONTENT/$id" > "$work/$id.log" 2>&1; then
  34. echo "ok $kind $id"
  35. else
  36. echo "FAIL $kind $id"
  37. tail -3 "$work/$id.log"
  38. fi
  39. rm -f "$work/shot.png"
  40. done <<< "$kinds"
  41. for check in check_dump_structure check_hotswap_keys check_hotswap_video check_splat check_transition check_video_sequence check_video_start; do
  42. echo "== $check"
  43. "$HERE/$check.sh" "$BINARY" "$ASSETS" "$CONTENT" 2>&1 | tail -4
  44. done