68 lines
2.9 KiB
Shell
Executable file
68 lines
2.9 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Runs a subset of WPT media-source/ in Nacre and prints pass counts (S027). Offline after the first run.
|
|
# - fetches web-platform-tests at $WPT_REV (sparse: media-source, media, resources, common) into target/wpt once
|
|
# - serves it on 127.0.0.1:$WPT_PORT (tests/wpt-mse/server.py) with our testharnessreport.js
|
|
# - runs tests/wpt-mse/driver.html in a hidden smoke run (tools/smoke.sh): every test in an iframe, $WPT_TIMEOUT s each
|
|
# - writes <outdir>/wpt/results.json and prints per-file and total subtest pass counts
|
|
# Usage: tools/wpt-mse.sh [outdir] [file ...] (files default to the subset below)
|
|
# Not run: dedicated-worker/, managed/ (ManagedMediaSource), mse-for-webcodecs/, idlharness and *.window.js (need
|
|
# wptserve's generated wrappers), the reftest mediasource-video-is-visible, iamf, and the long config-change playbacks.
|
|
set -eu
|
|
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
rev=${WPT_REV:-4e9e53b6fc1dad91c48a71593041b2a325d5401b}
|
|
port=${WPT_PORT:-8790}
|
|
wpt=$root/target/wpt
|
|
out=${1:-$root/target/smoke/wpt-mse-$(date +%H%M%S)}
|
|
shift || true
|
|
mkdir -p "$out/wpt"
|
|
|
|
if [ ! -d "$wpt/media" ]; then
|
|
[ -d "$wpt/.git" ] || git clone --filter=blob:none --no-checkout https://github.com/web-platform-tests/wpt.git "$wpt"
|
|
git -C "$wpt" sparse-checkout set media-source media resources common
|
|
git -C "$wpt" fetch --depth 1 origin "$rev"
|
|
git -C "$wpt" checkout -q "$rev"
|
|
fi
|
|
|
|
if [ $# -gt 0 ]; then
|
|
files=("$@")
|
|
else
|
|
mapfile -t files < <(cd "$wpt/media-source" && ls -1 ./*.html | sed 's|^\./||' |
|
|
grep -v -e '^mediasource-config-change-' -e '^mediasource-video-is-visible' -e '^mediasource-iamf-')
|
|
fi
|
|
printf '%s\n' "${files[@]}" | python3 -c 'import json,sys; print(json.dumps([l.strip() for l in sys.stdin if l.strip()]))' >"$out/wpt/tests.json"
|
|
|
|
python3 -I "$root/tests/wpt-mse/server.py" "$wpt" "$out/wpt/tests.json" "$out/wpt/results.json" "$port" &
|
|
server=$!
|
|
trap 'kill $server 2>/dev/null' EXIT
|
|
rm -f "$out/wpt/results.json"
|
|
|
|
timeout_each=${WPT_TIMEOUT:-75}
|
|
cat >"$out/wpt/wpt.txt" <<SCRIPT
|
|
# Generated by tools/wpt-mse.sh
|
|
wait 2
|
|
open http://127.0.0.1:$port/driver.html?timeout=$timeout_each
|
|
waitload 30
|
|
waitfor $(( ${#files[@]} * (timeout_each + 5) )) window.__all && window.__all.done
|
|
shot wpt-driver
|
|
status done
|
|
quit
|
|
SCRIPT
|
|
SMOKE_TIMEOUT=$(( ${#files[@]} * (timeout_each + 5) + 120 )) "$root/tools/smoke.sh" "$out/wpt/wpt.txt" "$out" || true
|
|
|
|
python3 - "$out/wpt/results.json" <<'PY'
|
|
import json, sys
|
|
try:
|
|
files = json.load(open(sys.argv[1]))
|
|
except OSError:
|
|
sys.exit("wpt-mse: no results (the driver did not finish)")
|
|
total = passed = 0
|
|
for name, result in files.items():
|
|
tests = result.get("tests", [])
|
|
ok = sum(1 for t in tests if t["status"] == 0)
|
|
total += len(tests)
|
|
passed += ok
|
|
note = "" if result.get("done") else " (no completion: " + str(result.get("status")) + ")"
|
|
print(f"{ok:4}/{len(tests):<4} {name}{note}")
|
|
print(f"wpt-mse: {passed}/{total} subtests passed in {len(files)} files")
|
|
PY
|